When I try to Maximize a Form when it is in a Minimized state, (I am using Windows Form) It will not open. Can't figure why.
Here is an example of what I'm doing:
Button_X_Click(args, Events e)
{
Form1.ActiveForm.WindowState = WindowState.Minimized;
DialogResult dr = MessageBox.Show
(
this,
"Would you like to open Form?",
"Title",
MessageBoxButtons.YesNo
)
if (dr == System.Windows.Forms.DialogResult.Yes)
{
Form1.ActiveForm.WindowState =
FormWindowState.Maximized;
MessageBox.Show("Done"); //For Testing
}
Somehow, it does not open my Form. It does show me the "Done" MessageBox.
Could use some help here ;)
You need to have a reference to the form you are trying to manipulate. I am expecting to see something like:
form1.WindowState = FormWindowState.Maximized;
If this code is on the current form you are designing, then I am expecting to see something like:
this.WindowState = FormWindowState.Maximized;
A bit more context would be helpful.
Anyway this will work for you:
void Button_X_Click(object args, Events e) {
Form f = Form1.ActiveForm;
Form1.ActiveForm.WindowState = WindowState.Minimized;
DialogResult dr = MessageBox.Show( this, "Would you like to open Form?",
"Title", MessageBoxButtons.YesNo );
if (dr == System.Windows.Forms.DialogResult.Yes) {
f.WindowState = FormWindowState.Maximized;
MessageBox.Show("Done"); //For Testing
}
}
NOTE : The arguments of your Button_X_Click
have something wrong, I just corrected it a little without caring too much about what Events
is, in fact I think you mean EventArgs
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.