To bring a modeless Windows Form to its previous position upon a click event, I am trying to use the code shown below, but its not working.
Please let me know if I am missing anything.
public void SetFocus()
{
this.Focus();
this.BringToFront();
if (this.WindowState==FormWindowState.Minimized)
this.Select();
}
If the form is minimized and you want to make it visible, you'll need to restore it. You do this by setting its WindowState
property to FormWindowState.Normal
.
For example, change your code to this instead:
public void SetFocus()
{
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
this.Focus();
this.BringToFront();
}