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. Enable/Disable Menuitems of MdiParent from MdiChild

Enable/Disable Menuitems of MdiParent from MdiChild

Scheduled Pinned Locked Moved C#
helpquestion
8 Posts 2 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.
  • Z Offline
    Z Offline
    zenithmaximus
    wrote on last edited by
    #1

    Hi all, I'm trying to manipulate menuitems of a MdiParent from MdiChild, here's the code that i have frmMain <- the MdiParent Form private void Main_Load(object sender, System.EventArgs e) { frmsignon fs = new frmsignon(); fs.MdiParent = this; fs.Show(); } i'm trying the below code from my MdiChild form to manipulate the menus on my MdiParent form private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = new frmMain(); fM.menuItem1.Enabled = false; } this code has no build errors, but it has no effect upon run time, the menuItem1 of my MdiParent form is still ENABLED. What seems to be missing? Please help me make this work. Thanks in advance:-D

    -::maximus::-

    A 1 Reply Last reply
    0
    • Z zenithmaximus

      Hi all, I'm trying to manipulate menuitems of a MdiParent from MdiChild, here's the code that i have frmMain <- the MdiParent Form private void Main_Load(object sender, System.EventArgs e) { frmsignon fs = new frmsignon(); fs.MdiParent = this; fs.Show(); } i'm trying the below code from my MdiChild form to manipulate the menus on my MdiParent form private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = new frmMain(); fM.menuItem1.Enabled = false; } this code has no build errors, but it has no effect upon run time, the menuItem1 of my MdiParent form is still ENABLED. What seems to be missing? Please help me make this work. Thanks in advance:-D

      -::maximus::-

      A Offline
      A Offline
      ashukasama
      wrote on last edited by
      #2

      use this.Parent Form2 fr2 = (Form2)this.Parent; and make menuItem1 public but better approach is to make function in MDI parent to enable and disable menu item and call function in child using fr2. :)

      Z 1 Reply Last reply
      0
      • A ashukasama

        use this.Parent Form2 fr2 = (Form2)this.Parent; and make menuItem1 public but better approach is to make function in MDI parent to enable and disable menu item and call function in child using fr2. :)

        Z Offline
        Z Offline
        zenithmaximus
        wrote on last edited by
        #3

        Thanks ashuka :-D you mean changing the frmMain fM = new frmMain(); to Form2 fr2 = (Form2)this.Parent; ? menuItem1 is already public.

        -::maximus::-

        A 1 Reply Last reply
        0
        • Z zenithmaximus

          Thanks ashuka :-D you mean changing the frmMain fM = new frmMain(); to Form2 fr2 = (Form2)this.Parent; ? menuItem1 is already public.

          -::maximus::-

          A Offline
          A Offline
          ashukasama
          wrote on last edited by
          #4

          yeah dear :) Ashu Ashish Kasama

          Z 1 Reply Last reply
          0
          • A ashukasama

            yeah dear :) Ashu Ashish Kasama

            Z Offline
            Z Offline
            zenithmaximus
            wrote on last edited by
            #5

            Hmmm... Im getting this error: An unhandled exception of type 'System.InvalidCastException' occurred Additional information: Specified cast is not valid. my code on the MDIChild form looks like this now private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = (frmMain)this.Parent; fM.menuItem1.Enabled = false; }

            -::maximus::-

            A 1 Reply Last reply
            0
            • Z zenithmaximus

              Hmmm... Im getting this error: An unhandled exception of type 'System.InvalidCastException' occurred Additional information: Specified cast is not valid. my code on the MDIChild form looks like this now private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = (frmMain)this.Parent; fM.menuItem1.Enabled = false; }

              -::maximus::-

              A Offline
              A Offline
              ashukasama
              wrote on last edited by
              #6

              where you launch it frmSignOn frm = new frmSignOn(); frm. MdiParent = this; frm.Show(); and at the time of private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = (frmMain)this.MdiParent; fM.menuItem1.Enabled = false; } :)

              Z 1 Reply Last reply
              0
              • A ashukasama

                where you launch it frmSignOn frm = new frmSignOn(); frm. MdiParent = this; frm.Show(); and at the time of private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = (frmMain)this.MdiParent; fM.menuItem1.Enabled = false; } :)

                Z Offline
                Z Offline
                zenithmaximus
                wrote on last edited by
                #7

                Thanks much! :-D it really worked! got what went wrong private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = (frmMain)this.Parent; frmMain fM = (frmMain)this.MdiParent; fM.menuItem1.Enabled = false; } Thanks Ashu :cool: Regards

                -::maximus::-

                A 1 Reply Last reply
                0
                • Z zenithmaximus

                  Thanks much! :-D it really worked! got what went wrong private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = (frmMain)this.Parent; frmMain fM = (frmMain)this.MdiParent; fM.menuItem1.Enabled = false; } Thanks Ashu :cool: Regards

                  -::maximus::-

                  A Offline
                  A Offline
                  ashukasama
                  wrote on last edited by
                  #8

                  you are welcome :)

                  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