how to check if any textbox has changed on a form?
-
Hi, i have several textBoxes on a form and i want to set a Boolean to false if a key is pressed in any of them. Is there a quick method to do that instead of "textBox1_KeyPress", "textBox2_KeyPress" ect... ? Thanks in advance :rose:
You can have one KeyPress event handler for all of the textboxes
#region signature my articles #endregion
-
Hi, i have several textBoxes on a form and i want to set a Boolean to false if a key is pressed in any of them. Is there a quick method to do that instead of "textBox1_KeyPress", "textBox2_KeyPress" ect... ? Thanks in advance :rose:
or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox). :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox). :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
Luc Pattyn wrote:
or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox).
Thx allot it works. I am also interested in Giorgi solution as i do not know how to do what he tells.
-
Luc Pattyn wrote:
or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox).
Thx allot it works. I am also interested in Giorgi solution as i do not know how to do what he tells.
If you are using Visual Studio then select the button you want to set event handler for and switch to the event list in properties window. Find the KeyPress event there and choose the event handler you want to attach from the drop-down list. For each button select the same event.
#region signature my articles #endregion