J
Jerad Rose
I have a WinForms application in .NET 2.0. I'm trying to set the
WindowState property of my form prior to it being visible, but it's doing
some weird stuff.
My code looks something like this:
private void Form1_Load(object sender, EventArgs e)
{
this.Visible = false;
this.WindowState = FormWindowState.Maximized;
}
However, when the form finally shows, it is not maximized -- it's still set
to normal.
On the other hand, if I don't set this.Visible = false, then it will
maximize the form, but it will also immediately make the form visible when
the this.WindowState property is set.
Neither of these are the desired results. I am performing some operations
based on the form size after it is maximized, so I need the form's size to
reflect the maximized state, but I don't want the form to be visible until
after these operations are complete.
Question 1) Why does it behave this way? Is this intended, or was this just
an oversight (or even a bug)?
Question 2) Are there any workarounds to this? I have tried some other
things (setting Opacity = 0, which resulted in a weird flicker) but nothing
is producing a clean, flicker-free result.
Thanks in advance.
Jerad
WindowState property of my form prior to it being visible, but it's doing
some weird stuff.
My code looks something like this:
private void Form1_Load(object sender, EventArgs e)
{
this.Visible = false;
this.WindowState = FormWindowState.Maximized;
}
However, when the form finally shows, it is not maximized -- it's still set
to normal.
On the other hand, if I don't set this.Visible = false, then it will
maximize the form, but it will also immediately make the form visible when
the this.WindowState property is set.
Neither of these are the desired results. I am performing some operations
based on the form size after it is maximized, so I need the form's size to
reflect the maximized state, but I don't want the form to be visible until
after these operations are complete.
Question 1) Why does it behave this way? Is this intended, or was this just
an oversight (or even a bug)?
Question 2) Are there any workarounds to this? I have tried some other
things (setting Opacity = 0, which resulted in a weird flicker) but nothing
is producing a clean, flicker-free result.
Thanks in advance.
Jerad