同时输入两个文本框

Dim*_*dis 2 c# textbox

我在jQuery(在这里找到)中遇到了类似的问题,我试图根据我在C#中的需要对其进行修改,但我没有设法做到这一点.我想要的是标题所说的内容,我希望用户在一个文本框中键入一些文本,并将结果同时显示在另一个文本框中.这是我的看法(很明显,它不起作用),我试图KeyUp将第一个文本框的事件的参数传递给第二个文本框的相应事件,但看起来并不那么容易:

public mainFrm()
{
    InitializeComponent();

    this.txtFormat.KeyUp += new KeyEventHandler(txtFormat_KeyUp);
    this.txtNewFormat.KeyUp += new KeyEventHandler(txtNewFormat_KeyUp);
}

private void txtFormat_KeyUp(object sender, KeyEventArgs e)
{
    txtNewFormat_KeyUp(sender, e);
}

private void txtNewFormat_KeyUp(object sender, KeyEventArgs e)
{
}
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助.

Jar*_*Par 9

最简单的方法是只听一个TextChanged事件TextBox并将当前状态转发给另一个

public mainFrm()
{
    InitializeComponent();

    txtFormat.TextChanged += OnTextChanged;
}

private void OnTextChanged(object sender, EventArgs e)
{
    txtNewFormat.Text = txtFormat.Text;
}
Run Code Online (Sandbox Code Playgroud)