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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Enabling buttons at run time

Enabling buttons at run time

Scheduled Pinned Locked Moved C#
json
5 Posts 4 Posters 1 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.
  • T Offline
    T Offline
    tasumisra
    wrote on last edited by
    #1

    Hey guys, I have 5 buttons in my form. During the page load event only 1 will be enabled, rest all i have made it Enabled = false. I have one more button named as "More", when a user clicks on it, the buttons which are disabled should be enabled one by one. Can someone please give me a solution for this. Thanks, Vikas

    vikas da

    R realJSOPR V 3 Replies Last reply
    0
    • T tasumisra

      Hey guys, I have 5 buttons in my form. During the page load event only 1 will be enabled, rest all i have made it Enabled = false. I have one more button named as "More", when a user clicks on it, the buttons which are disabled should be enabled one by one. Can someone please give me a solution for this. Thanks, Vikas

      vikas da

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      Put this in your button handler:

      button5.Enabled = button4.Enabled;
      button4.Enabled = button3.Enabled;
      button3.Enabled = button2.Enabled;
      button2.Enabled = button1.Enabled;

      Regards, Rob Philpott.

      1 Reply Last reply
      0
      • T tasumisra

        Hey guys, I have 5 buttons in my form. During the page load event only 1 will be enabled, rest all i have made it Enabled = false. I have one more button named as "More", when a user clicks on it, the buttons which are disabled should be enabled one by one. Can someone please give me a solution for this. Thanks, Vikas

        vikas da

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        Write a method like this:

        private void ToggleButtonGroup(Button button)
        {
        button1.Enabled = (this.button1 == button);
        button2.Enabled = (this.button2 == button);
        button3.Enabled = (this.button3 == button);
        button4.Enabled = (this.button4 == button);
        }

        Call this method from each appropriate button handler. If you passed this.button4 to the method, button4 would be enabled, and the rest would be disabled.

        .45 ACP - because shooting twice is just silly
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

        modified on Monday, December 14, 2009 8:22 AM

        T 1 Reply Last reply
        0
        • T tasumisra

          Hey guys, I have 5 buttons in my form. During the page load event only 1 will be enabled, rest all i have made it Enabled = false. I have one more button named as "More", when a user clicks on it, the buttons which are disabled should be enabled one by one. Can someone please give me a solution for this. Thanks, Vikas

          vikas da

          V Offline
          V Offline
          vtchris peterson
          wrote on last edited by
          #4

          I would suggest putting the additional buttons in a Panel, then you can toggle just one Enabled property.

          1 Reply Last reply
          0
          • realJSOPR realJSOP

            Write a method like this:

            private void ToggleButtonGroup(Button button)
            {
            button1.Enabled = (this.button1 == button);
            button2.Enabled = (this.button2 == button);
            button3.Enabled = (this.button3 == button);
            button4.Enabled = (this.button4 == button);
            }

            Call this method from each appropriate button handler. If you passed this.button4 to the method, button4 would be enabled, and the rest would be disabled.

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            modified on Monday, December 14, 2009 8:22 AM

            T Offline
            T Offline
            tasumisra
            wrote on last edited by
            #5

            Thanks guys for your help

            vikas da

            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