Start form in center of the screen properly after FormWindowState.Minimized on start up

youki 1,021 Reputation points
2021-07-23T09:55:41.69+00:00

Hello,
If i minimize the form on start up and use FormWindowState.Normal, it opens at the position of the FormStartPosition.Manual in the top left corner and moves to the desired position of a defined StartPosition or defined location. This happens within milliseconds but you can see it.
It only happens the first time when you maximize it after the start. If you do it again it works normally.

I tried to define the location and the size on start up before and after WindowState = FormWindowState.Minimized but i can't figure it out.

PS: It also works normally, if i don't minimize the form on start up, obviously the minimizing generates the issue?!

Regards

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,892 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,913 questions
{count} votes

Accepted answer
  1. Castorix31 85,131 Reputation points
    2021-07-23T10:09:18.773+00:00

    If I do this on Form1_Load, it seems to work correctly (Windows 10, VS 2019) :

                CenterToScreen();
                WindowState = FormWindowState.Minimized;
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.