I have a form that contains text boxes and combo boxes. My problem is that when I click on a control, let's say a comboxbox, I can edit inside it but when I click outside, the main form where my controls are contained, my focus is still in the combobox.
How can I lose focus on a control when I click outside it?
Collapse
X
-
If I'm understanding you correctly, you want your controls to lose focus when you click on the form itself? There might be a better way to do this, but here's what I came up with.
Add a listener to the form's MouseClick event. Inside that method, put the following code...
This should clear the active control for the form and remove focus from your controls.Code:this.ActiveControl = null;
If that's not what you meant, can you please clarify? -
Sorry if I did not clarify things up. Even I find it hard to explain it further. I have this combobox with AutoCompleteMod e set to SuggestAppend.
My problem -> I click on the combobox and choose an item. Then I click the form and use my mouse wheel to scroll the whole form but what I'm scrolling here is not the whole form as to what I intend to do but just the items inside the combobox.
The same goes when I click on a textbox inside a tablelayoutpane l which is inside a groupbox.
I assume you had the idea because your code helped me but now every time I click my main form it scrolls back to where I have my focus. I want my form in a way that I have my form scrolled to where I'm at and just have to click the main form whenever I want to scroll up or down.Comment
Comment