I have a form that covers the entire screen. I have a textbox on it, which is usually hidden, but appears when the user clicks, drags, and then leaves. After that, the user can enter any value in the text box. After entering, ideally, the user should be able to click outside the text box, and then continue normal maintenance.
By means of a regular service, I mean that the form should begin to receive all events. What I have done so far is the TextBox KeyDown event; when the Escape key is pressed, I set the focus to the main form as follows:
this.Focus(); //where this is mainform.
But this does not seem to work, as the textbox still continues to receive all the keys. I have a KeyDown handler for both Form and textbox , and I have verified that all KeyDown events are passed to the TextBox. I have a textbox Leave event handler that never gets called.
This textbox is the only form control, and the main form is used to draw shapes (if that matters).
So, how can I make this textbox lose focus when the user clicks on it.
source share