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. MDI Form

MDI Form

Scheduled Pinned Locked Moved C#
help
3 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.
  • D Offline
    D Offline
    DucLinh
    wrote on last edited by
    #1

    :doh:I designed 2 form. One is MDI form(i named frmMain) and another is child form (i named frmLoggon). On frmMain form i got a menuItem (i named menuItem1) On frmMain Form private void frmMain_Load(object sender, System.EventArgs e) { frmLoggon fLoggon = new frmLoggon(); fLoggon.ShowInTaskbar = false; fLoggon.ShowDialog(this); } On frmLoggon Form i got a button (i named btExit) private void btExit_Click(object sender, System.EventArgs e) { frmMain fMain = new frmMain(); fMain.Menu.MenuItem[0].Enabled = false; this.close(); } but the menuItem1 not disabed. Please help me as posible as you can. Thanks Mr Duc Linh Nguyen

    M I 2 Replies Last reply
    0
    • D DucLinh

      :doh:I designed 2 form. One is MDI form(i named frmMain) and another is child form (i named frmLoggon). On frmMain form i got a menuItem (i named menuItem1) On frmMain Form private void frmMain_Load(object sender, System.EventArgs e) { frmLoggon fLoggon = new frmLoggon(); fLoggon.ShowInTaskbar = false; fLoggon.ShowDialog(this); } On frmLoggon Form i got a button (i named btExit) private void btExit_Click(object sender, System.EventArgs e) { frmMain fMain = new frmMain(); fMain.Menu.MenuItem[0].Enabled = false; this.close(); } but the menuItem1 not disabed. Please help me as posible as you can. Thanks Mr Duc Linh Nguyen

      M Offline
      M Offline
      Meysam Mahfouzi
      wrote on last edited by
      #2

      frmMain fMain = new frmMain();
      fMain.Menu.MenuItem[0].Enabled = false;

      You are just disabling the menuitem which resides on temporary MDI instantiated form. It exists only in btExit_Click procedure scope. So you need some permanent refrence to your MDI form. I'd recommend passing the MDI reference as a parameter to your child form's constructor like this:

      private void frmMain_Load(object sender, System.EventArgs e)
      {
      frmLoggon fLoggon = new frmLoggon(this);
      fLoggon.ShowInTaskbar = false;
      fLoggon.ShowDialog(this);
      }

      In your frmLoggon constructor:

      frmMain _parent;
      public frmLoggon(frmMain parent)
      {
      //save a reference to the MDI form.
      _parent = parent;
      }

      and finally:

      private void btExit_Click(object sender, System.EventArgs e)
      {
      _parent.Menu.MenuItem[0].Enabled = false;
      this.close();
      }

      I hope this helps. abcdabcdabcdabcda Don't forget, that's

      Persian Gulf

      not Arabian gulf!


      Murphy:
      Click Here![^]


      I'm thirsty like sun, more landless than wind...

      1 Reply Last reply
      0
      • D DucLinh

        :doh:I designed 2 form. One is MDI form(i named frmMain) and another is child form (i named frmLoggon). On frmMain form i got a menuItem (i named menuItem1) On frmMain Form private void frmMain_Load(object sender, System.EventArgs e) { frmLoggon fLoggon = new frmLoggon(); fLoggon.ShowInTaskbar = false; fLoggon.ShowDialog(this); } On frmLoggon Form i got a button (i named btExit) private void btExit_Click(object sender, System.EventArgs e) { frmMain fMain = new frmMain(); fMain.Menu.MenuItem[0].Enabled = false; this.close(); } but the menuItem1 not disabed. Please help me as posible as you can. Thanks Mr Duc Linh Nguyen

        I Offline
        I Offline
        Inpreet Singh
        wrote on last edited by
        #3

        Hi, I don't know that, what i am goin to tell u is good wayout but I am sure this will work. Ur menuItem is not disable bcoz u r make another instance of the main form n then on that u r making it disabled so u need to disable it with first instance. do one thing take a global integer set it as 0 then check on frmMain_Enter() event. if it is still 0 then don't run Menu.MenuItem[0].Enabled = false; set interger to 0 so that u can chk it correctly again. other run this. Now exiting from frmLoggon thats btExit_Click event set this interger to 1. simple. I hope u understand what I written. Good Bye Inpreet Singh

        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