发生TextBox A的TextChanged事件时TextBox B的FireTextChanged事件

时间:2015-01-09 12:16:56

标签: c# winforms events textbox event-handling

我有两个TextBoxesAB

我希望B模仿A的行为。因此,只要A的文字发生变化,B的文字也会发生变化。 只要B的文字发生变化,就可以将A的文字设置为A的文字。但由于B具有AutoComplete选项,因此除非AutoComplete的TextChange事件被触发,否则此B将无效。

因此,对于A中的每个TextChange,我想在B中触发TextChange。

我怎样才能做到这一点?

2 个答案:

答案 0 :(得分:1)

void TextChanged_A(object sender, EventArgs e)
{
   //Do Anything
   //Then
    TextChanged_B(B,null);
}

void TextChanged_B(object sender, EventArgs e)
{
    //Do Anything
}

答案 1 :(得分:-1)

一个简单的方法是TextBox 1的TextChanged事件。

private void textBox1_TextChanged(object sender, EventArgs e)
    {
        textBox2.Text = textBox1.Text;
    }
相关问题