I have a main form and login form.
I'm calling login form from main form but I can't get to disable main form(I can click on menu)
and also when i click on cancel button(in login form), I want to close both forms.
How to do that?
I have a main form and login form.
I'm calling login form from main form but I can't get to disable main form(I can click on menu)
and also when i click on cancel button(in login form), I want to close both forms.
How to do that?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted May 15, 2009, 5:33 AM
For closing form you can use the following method:
To close all Mdi child forms from code within the Mdi parent itself, you can use:
foreach (Form f in this.MdiChildren)
{
f.Close();
}
To close them from some other form, replace 'this' with a reference to the Mdi Parent form.
To hide menu you can use following method:
You have some options; you could withhold display of the main form until the user was validated, and then hide the login form and open the main mdi form. To do what you have asked, a simple way to do it would be to set the menu's modifier property to public to make it available to your login form.
You can initialize the main form using something like this:
public Form1()Then, in whatever code runs within your login, once the user was validated, you could do something like this from the main form to enable the main form's menu and to dispose of the login form:
private void button1_Click(object sender, EventArgs e)