0

I have 2 textbox (textbox 1 & textbox 2 ); the textbox1 has numeric value such as $1,000. Now when i am in textbox2 and if i hit keystrokes like (= or + or pageup or pagedown etc...) the textbox1 value should appear in textbox2.

The reason behind this is to enable customers improve speed in processsing/ filling data.

4

3 回答 3

1

如何使用如下函数在 textbox2 上添加 keyPress 事件:

    private void textbox2_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (e.KeyChar == '+')
        {
            textbox2.Text = textbox1.Text;
        }
    }
于 2012-04-17T08:07:38.713 回答
1

你可以试试这个:

protected void textbox2_TextChanged(object sender, EventArgs e)
{
  if(textbox2.Text=="+"||textbox2.Text=="=")
  textbox2.Text=textbox1.Text;
}
于 2012-04-17T08:08:14.080 回答
1

我不知道我是否明白你需要什么,无论如何试试这个:

private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.PageDown ||
        e.KeyCode == Keys.PageUp ||
        e.KeyCode == Keys.Oemplus ||
        e.KeyCode == Keys.Add ||
        (e.KeyCode == Keys.D0 && e.Shift))
    {
        textBox2.Text = textBox1.Text;
        e.Handled = true;
        e.SuppressKeyPress = true;
    }
}
于 2012-04-17T08:10:00.620 回答