KeyPress Event for TextBox
-
Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,
Prya
-
Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,
Prya
I thnk there's a property on the textbox that makes the textbox register the enter key.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,
Prya
Use the KeyDown event instead of the KeyPress and write in it:
if(e.KeyCode == Keys.Enter)
-
Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,
Prya