C # Windows Form startup is always kept to a minimum

I have developed a C # Windows Form. Windows Form works fine at first. However, once starting a Windows Form is always minimized and I have no idea. I have WindowState

Normal

not checked Minimized

. How can I fix this, thanks!


Edit:

I comment out each block of code to narrow down my search to find the problem. And I found that I was using Drive Detector in my MainForm . When this instance has been created, the invocation window form must be passed as a parameter to the constructor. Otherwise it Drive Detector

will create a hidden shape. However, MainForm will be kept to a minimum.

The code below will NOT create a hidden form.

driveDetector = new DriveDetector(this);

      

The code below will create a hidden form, it will interfere with calling Windows Form.

driveDetector = new DriveDetector();

      

+3
c # winforms


source to share


7 replies


try adding this code to form load event and test



this.WindowState = FormWindowState.Normal;

      

+4


source to share


Just try adding it from the code level to tell the Windows state like this.



    private void Form1_Load(object sender, EventArgs e)
    {
        this.WindowState = FormWindowState.Normal;
    }

      

+2


source to share


you should use WindowState = FormWindowState.Maximized

if you want to open your windows full screen by default. You can do this programmatically in an event Form load

.

There are other options available from which you can control the opening of the Windows Form.

+2


source to share


1. Check if the size of the form was smaller.

2. Try to rebuild your solution.

3.Add the form load event from your form event properties and add the following code to it

this.WindowState = FormWindowState.Normal;

+2


source to share


Try to do this on form triggered event

    bool bIsLoaded = false;
    private void Form1_Activated(object sender, EventArgs e)
    {
        if (!bIsLoaded)
        {
            this.WindowState = FormWindowState.Maximized;
            bIsLoaded = true;
        }
    }

      

+2


source to share


I comment out each block of code to narrow down my search to find the problem. And I found that I was using Drive Detector in my MainForm . When this instance has been created, the invocation window form must be passed as a parameter to the constructor. Otherwise it Drive Detector

will create a hidden shape. However, MainForm will be kept to a minimum.

The code below will NOT create a hidden form.

driveDetector = new DriveDetector(this);

      

The code below will create a hidden form, it will interfere with calling Windows Form.

driveDetector = new DriveDetector();

      

0


source to share


Try the following:

Topmost = true;

      

In your Form_Load event

0


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics