C#:Problem in MenuStrip Hiding in MDIParent. Help Me!
-
hi i am creating a login page.Inthe form load itself i need to hide the MenuStrip in MDI Parent to HIDE, When the users gives the correct passwd and pushes the Loginbutton , My MDIParent1 forms menustrip should be visible . c my code . but it doesnt works. Any body pls clear my doubt.
private void LoginForm_Load(object sender, EventArgs e) { mdifrm = new MDIParent1(); mdifrm.menuStrip.Visible = false; }
I had created formobj mdifrm and made it visible false on load. :doh: this also not works.private void btnLogin_Click_1(object sender, EventArgs e) { if (strPasswd == dsUsers.Tables[0].Rows[0].ItemArray[0].ToString()) { this.mdifrm.menuStrip.Visible = true; this.Hide(); } else { MessageBox.Show("Incorrect Password","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
thanks in adv kssk :doh:senthil
-
hi i am creating a login page.Inthe form load itself i need to hide the MenuStrip in MDI Parent to HIDE, When the users gives the correct passwd and pushes the Loginbutton , My MDIParent1 forms menustrip should be visible . c my code . but it doesnt works. Any body pls clear my doubt.
private void LoginForm_Load(object sender, EventArgs e) { mdifrm = new MDIParent1(); mdifrm.menuStrip.Visible = false; }
I had created formobj mdifrm and made it visible false on load. :doh: this also not works.private void btnLogin_Click_1(object sender, EventArgs e) { if (strPasswd == dsUsers.Tables[0].Rows[0].ItemArray[0].ToString()) { this.mdifrm.menuStrip.Visible = true; this.Hide(); } else { MessageBox.Show("Incorrect Password","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
thanks in adv kssk :doh:senthil
You did VB6 before right? What you are doing is this: you create a NEW invisible(because never shown through .Show) mdi-form and set it's visibility to false. But you will have to acces the mdi-form-object that is shown in your app! The easiest way is to use the parent/owner property of your form (you set the owner/mdi-parent of the login-form to the mdi-form) and use this:
this.Parent.Hide();
-
hi i am creating a login page.Inthe form load itself i need to hide the MenuStrip in MDI Parent to HIDE, When the users gives the correct passwd and pushes the Loginbutton , My MDIParent1 forms menustrip should be visible . c my code . but it doesnt works. Any body pls clear my doubt.
private void LoginForm_Load(object sender, EventArgs e) { mdifrm = new MDIParent1(); mdifrm.menuStrip.Visible = false; }
I had created formobj mdifrm and made it visible false on load. :doh: this also not works.private void btnLogin_Click_1(object sender, EventArgs e) { if (strPasswd == dsUsers.Tables[0].Rows[0].ItemArray[0].ToString()) { this.mdifrm.menuStrip.Visible = true; this.Hide(); } else { MessageBox.Show("Incorrect Password","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
thanks in adv kssk :doh:senthil
Just a piece of suggestion... Why don't you use a dialog box for your login? In that way your main form/MDI Parent form is hidden and it will only be visible not until the user gives the correct username/password.. Maybe you might want to consider this for your login: :rolleyes: **Create two forms, one is the Login Form, and the other is the Main Form. LOGIN FORM: 1. Add a textbox control (say txtPassword) and button controls (OK & Cancel), set the form's FormBorderStyle to FixedDialog & set the ControlBox to false (this is one way on how you create your own custom dialog box :) ) 2. on the OnClick event of the OK button, do your validation... i.e. ******** private void button1_Click(object sender, EventArgs e) { if (txtPassword.Text == "whatever your condition is...") { this.Close(); //once the user inputs the correct username/password, just close //the Login Form.. } } ******** then this is just what you need to code in the MAIN FORM.. ******** private void MainForm_Load(object sender, EventArgs e) { LoginForm log = new LoginForm(); log.ShowDialog(); } ********* With this kind of program, you are more assured that your Main form will be displayed only if the user will input the correct username and password. Hope this helps. :)
-
You did VB6 before right? What you are doing is this: you create a NEW invisible(because never shown through .Show) mdi-form and set it's visibility to false. But you will have to acces the mdi-form-object that is shown in your app! The easiest way is to use the parent/owner property of your form (you set the owner/mdi-parent of the login-form to the mdi-form) and use this:
this.Parent.Hide();
i think u didnt understand my exact problem. My problem is not hiding or making my MDIparent as visible. I have two forms FORM1 ,FORM2. FORM1 is MDIParent. FORM2 is Loginform i have a menustrp in FORM1(MDIParent).That menustrip should be invisible till the user enters the correct password(I had checked it in my code) in the FORM2(Login form), so if the passwd is correct menustrip should be visible! Hope now u can give me right idea.
senthil
-
i think u didnt understand my exact problem. My problem is not hiding or making my MDIparent as visible. I have two forms FORM1 ,FORM2. FORM1 is MDIParent. FORM2 is Loginform i have a menustrp in FORM1(MDIParent).That menustrip should be invisible till the user enters the correct password(I had checked it in my code) in the FORM2(Login form), so if the passwd is correct menustrip should be visible! Hope now u can give me right idea.
senthil