how can i enable back newToolStripMenuItem to true
-
my main form is form1.
private void newToolStripMenuItem_Click(object sender, EventArgs e) { newToolStripMenuItem.Enabled = false; Form2 frm2 = new Form2(); frm2.Owner = this; frm2.Show();
how can i enable back newToolStripMenuItem to true if the form2 to is closed i tried to create if form2 close event but i can't get the intelisense of newToolStripMenuItem -
my main form is form1.
private void newToolStripMenuItem_Click(object sender, EventArgs e) { newToolStripMenuItem.Enabled = false; Form2 frm2 = new Form2(); frm2.Owner = this; frm2.Show();
how can i enable back newToolStripMenuItem to true if the form2 to is closed i tried to create if form2 close event but i can't get the intelisense of newToolStripMenuItemSubscribe to the
FormClosed
event of frm2 and enable the menu item.private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
newToolStripMenuItem.Enabled = false;Form2 frm2 = new Form2(); frm2.Owner = this; frm2.FormClosed += new FormClosedEventHandler(frm2\_FormClosed); frm2.Show();
}
private void frm2_FormClosed(object sender, FormClosedEventArgs e)
{
newToolStripMenuItem.Enabled = true;
}Dave
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
Subscribe to the
FormClosed
event of frm2 and enable the menu item.private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
newToolStripMenuItem.Enabled = false;Form2 frm2 = new Form2(); frm2.Owner = this; frm2.FormClosed += new FormClosedEventHandler(frm2\_FormClosed); frm2.Show();
}
private void frm2_FormClosed(object sender, FormClosedEventArgs e)
{
newToolStripMenuItem.Enabled = true;
}Dave
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)i cant get the intelisense of newToolStripMenuItem.Enabled = true; in the event private void frm2_FormClosed(object sender, FormClosedEventArgs e) my newToolStripMenuItem is in my form1 and i want to show the form2 but disable the newToolStripMenuItem if form2 is loade already. and if form2 is close then the newToolStripMenuItem is enabled
-
i cant get the intelisense of newToolStripMenuItem.Enabled = true; in the event private void frm2_FormClosed(object sender, FormClosedEventArgs e) my newToolStripMenuItem is in my form1 and i want to show the form2 but disable the newToolStripMenuItem if form2 is loade already. and if form2 is close then the newToolStripMenuItem is enabled
-
because all the code I posted goes in form1. Form2 doesn't know about form1, and shouldn't, and doesn't ever need to know! Therefore you can't access it's instance properties, methods, controls etc... Form1 knows about form2 however, so it can listen for it's FormClosed event (and any others too) and react accordingly.
Dave
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)