When I click an item on menu on MainForm I set it's enable property is false to open a childForm. When I close childForm I want to set menuItem on MainForm is true to can choose it again but I couldn't do that.
Please tell me how can I do like that
Thank you very much !

How can enable or disable mainmenu's items on MainForm from childForm ?
Leo13
Form1.cs:
private void form2ToolStripMenuItem_Click(object sender, EventArgs e)
{
form2ToolStripMenuItem.Enabled = false;
MenuItemChildForm.Form2 frm = new Form2();
frm.LinkedMenuItem = form2ToolStripMenuItem;
frm.Show(this);
}
Form2.cs:
private ToolStripItem linkedMenuItem;
public ToolStripItem LinkedMenuItem
{
set
{
linkedMenuItem = value;
}
}
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
linkedMenuItem.Enabled = true;
}
Shankar Pal
Hi
I would prefer to show the child form like this code in the main form so that the user does not able to access the Parent Form without closing the child form.
private void btnChild_Form_Click(object sender, EventArgs e)
{
Form1 child_Form = new Form1();
child_Form.ShowDialog();
}
Hope this helps.
mabxsi
You won't be able to access the menu from the child form, because the menu on the main form is marked as private.
You should change the 'modifiers' property of the menu to 'public' or 'internal'. That way you can access the menu from the mdiparent property of the childform (don't forget to cast the mdiparent property to the type of the mainform).
Sven