How to force a focus on a control in windows forms
Ok, finally found the answer:
As I said my textbox is inside user control which is inside panel which is inside a form. When I need my user control I add it to panel. To get focus on my textbox I have to firstly focus my user control so something like this: In my top Form:
panel.Controls.Add(myUserControl);
myUserControl.Focus();
and then in my user control:
myTextBox.Select();
Note that if I used: myTextBox.Focus() it wouldn't work (don't know why). Also if I used myUserControl.Select() instead of myUserControl.Focus() it wouldn't work either.
This seems to be the only combination which works.
You could do these logic steps to set your control to be the focus:
your_control.Select();
your_control.Focus();
Enjoy! :)