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. how can i enable back newToolStripMenuItem to true

how can i enable back newToolStripMenuItem to true

Scheduled Pinned Locked Moved C#
question
5 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.
  • C Offline
    C Offline
    crisjala
    wrote on last edited by
    #1

    my main form is form1. private void newToolStripMenuItem_Click(object sender, EventArgs e) { newToolStripMenuItem.Enabled = false; Form2 frm2 = new Form2(); frm2.Owner = this; frm2.Show(); how can i enable back newToolStripMenuItem to true if the form2 to is closed i tried to create if form2 close event but i can't get the intelisense of newToolStripMenuItem

    D 1 Reply Last reply
    0
    • C crisjala

      my main form is form1. private void newToolStripMenuItem_Click(object sender, EventArgs e) { newToolStripMenuItem.Enabled = false; Form2 frm2 = new Form2(); frm2.Owner = this; frm2.Show(); how can i enable back newToolStripMenuItem to true if the form2 to is closed i tried to create if form2 close event but i can't get the intelisense of newToolStripMenuItem

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      Subscribe to the FormClosed event of frm2 and enable the menu item.

      private void newToolStripMenuItem_Click(object sender, EventArgs e)
      {
      newToolStripMenuItem.Enabled = false;

      Form2 frm2 = new Form2();
      frm2.Owner = this;
      frm2.FormClosed += new FormClosedEventHandler(frm2\_FormClosed);
      frm2.Show();
      

      }
      private void frm2_FormClosed(object sender, FormClosedEventArgs e)
      {
      newToolStripMenuItem.Enabled = true;
      }

      Dave
      Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Why are you using VB6? Do you hate yourself? (Christian Graus)

      C 1 Reply Last reply
      0
      • D DaveyM69

        Subscribe to the FormClosed event of frm2 and enable the menu item.

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
        newToolStripMenuItem.Enabled = false;

        Form2 frm2 = new Form2();
        frm2.Owner = this;
        frm2.FormClosed += new FormClosedEventHandler(frm2\_FormClosed);
        frm2.Show();
        

        }
        private void frm2_FormClosed(object sender, FormClosedEventArgs e)
        {
        newToolStripMenuItem.Enabled = true;
        }

        Dave
        Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Why are you using VB6? Do you hate yourself? (Christian Graus)

        C Offline
        C Offline
        crisjala
        wrote on last edited by
        #3

        i cant get the intelisense of newToolStripMenuItem.Enabled = true; in the event private void frm2_FormClosed(object sender, FormClosedEventArgs e) my newToolStripMenuItem is in my form1 and i want to show the form2 but disable the newToolStripMenuItem if form2 is loade already. and if form2 is close then the newToolStripMenuItem is enabled

        C 1 Reply Last reply
        0
        • C crisjala

          i cant get the intelisense of newToolStripMenuItem.Enabled = true; in the event private void frm2_FormClosed(object sender, FormClosedEventArgs e) my newToolStripMenuItem is in my form1 and i want to show the form2 but disable the newToolStripMenuItem if form2 is loade already. and if form2 is close then the newToolStripMenuItem is enabled

          C Offline
          C Offline
          crisjala
          wrote on last edited by
          #4

          error does not exist in the current context

          D 1 Reply Last reply
          0
          • C crisjala

            error does not exist in the current context

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            because all the code I posted goes in form1. Form2 doesn't know about form1, and shouldn't, and doesn't ever need to know! Therefore you can't access it's instance properties, methods, controls etc... Form1 knows about form2 however, so it can listen for it's FormClosed event (and any others too) and react accordingly.

            Dave
            Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Why are you using VB6? Do you hate yourself? (Christian Graus)

            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