Form.WindowState question

  • Thread starter Thread starter Valerie Hough
  • Start date Start date
V

Valerie Hough

I want to cause a form to come to the top of the z Order when it is notified
by another task (i.e. I want it to be right under the user's nose, not
having its title bar blinking on the task bar). If the window is minimized
at the time, then
WindowState = FormWidowState.Normal works perfectly. However, if the window
is not minimized, and it is covered by other windows on the user's desktop,
then I can not get it to come to the front except by:

WindowState = FormWidowState.Minimized
WindowState = FormWidowState.Normal.

Is there a better way of doing this?

Thanks in advance.
 
Tried Focus() too, no joy, but thanks anyway.

Below is code I use for exactly this purpose. MyForm2 is the form I want to
bring to the front. There are two Focus() lines, one for the active control
and one for the form. The code works for me with either commented in.

With MyForm2
If .WindowState = FormWindowState.Minimized Then .WindowState =
FormWindowState.Normal
If Not .ActiveControl Is Nothing Then .ActiveControl.Focus()
'.Focus()
End With
 
Tried Focus() too, no joy, but thanks anyway.

Hmmm. Maybe your form has no controls that will accept focus? Try
BringToFront
 
Back
Top