Hi folks,
I tacked this posting on to the end of a related thread, but got no
responses, so I'll try it as a new thread. Please excuse the reposting.
I have another TextBox focus problem. In my case, I have two forms whose
primary input is a text box, which must be disabled until an external
event occurs. In one form, the text box is in a panel, while on the
other it is on the main form. On both of them, if the form is minimised
when the event occurs, they set the window state to normal, and set the
TopMost property to true. When the event happens, I set the box.Visible
and the box.Enabled properties to true, then do the Focus() method. On
the first time the event occurs after the application is started, or if
the form is minimised when the event occurs and has to pop up, the
Focus() method returns false, and the textbox doesn't get focus. Every
time after that, it works fine. If the form is minimised then restored
again, the textbox *has* focus. If I hit the tab key, the textbox *gets*
focus. I have put in a diagnostic messagebox to display the properties
of the form, panel and textbox at the time of executing the Focus()
method, and all the properties are correct (everything is visible and
enabled and CanFocus is true). When that messagebox is dismissed, the
textbox *HAS* focus! I've tried setting the form's ActiveControl
property to the textbox as per the KnowledgeBase article, but that
doesn't work either.
I've run out of things to try. Any suggestions?
Thanks,
Ned