Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C#:Problem in MenuStrip Hiding in MDIParent. Help Me!

C#:Problem in MenuStrip Hiding in MDIParent. Help Me!

Scheduled Pinned Locked Moved C#
helpcsharp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kssknov
    wrote on last edited by
    #1

    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

    C K 2 Replies Last reply
    0
    • K kssknov

      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

      C Offline
      C Offline
      CKnig
      wrote on last edited by
      #2

      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();

      K 1 Reply Last reply
      0
      • K kssknov

        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

        K Offline
        K Offline
        kaluk
        wrote on last edited by
        #3

        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. :)

        1 Reply Last reply
        0
        • C CKnig

          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();

          K Offline
          K Offline
          kssknov
          wrote on last edited by
          #4

          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

          C 1 Reply Last reply
          0
          • K kssknov

            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

            C Offline
            C Offline
            CKnig
            wrote on last edited by
            #5

            I commented on your code - but the solution is simple: just implement some public function in FORM1 that shows/hides the menustrip and use this with ((FORM1)this.Parent).ShowMenuStrip(true);

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups