How can I bring a minimized model WinForm to its previously displayed position programmatically?

To bring a non-modal Windows Form to its previous position after a click event, I try to use the code shown below, but it doesn’t work.

Please let me know if I am missing something.

public void SetFocus() { this.Focus(); this.BringToFront(); if (this.WindowState==FormWindowState.Minimized) this.Select(); } 
+4
source share
1 answer

If the form is minimized and you want to make it visible, you need to restore it. You do this by setting the WindowState property to FormWindowState.Normal .

For example, change your code instead:

 public void SetFocus() { if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal; this.Focus(); this.BringToFront(); } 
+7
source

Source: https://habr.com/ru/post/1337751/


All Articles