Reputation: 409
Is there a "generic" event for a Windows Form that will trigger any time the user clicks anything on a form? I need to make sure that a certain text box has input focus at all times, so if the user clicks on a button (or anything else, for that matter), the input focus needs to be redirected to this text box.
Is there an event in the Form
class that will handle this, or do I have to handle a Click
event to all controls recursively on the form?
I did some digging but I can't find what I want so far.
Upvotes: 0
Views: 468
Reputation: 409
I actually figured something out - every time the TextBox
loses focus, just refocus it.
textBox.LostFocus += TextBox_LostFocus;
private void TextBox_LostFocus(object sender, EventArgs e)
{
textBox.Focus();
}
Upvotes: 1