How can I bring a minimized modeless WinForm to its previously displayed position programmatically?
To bring a modeless Windows Form to its previous position upon a click event, I am try开发者_运维百科ing 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();
}
精彩评论