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. a question about checkboxes ? help please ...

a question about checkboxes ? help please ...

Scheduled Pinned Locked Moved C#
questionhelp
9 Posts 6 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    hi all, i have 16 checkboxes in a form. (4 in a row and total 4 rows = 4x4) if any one checkbox is checked in a row, i want to disable others. how can i do this ?

    A M M E R 5 Replies Last reply
    0
    • L Lost User

      hi all, i have 16 checkboxes in a form. (4 in a row and total 4 rows = 4x4) if any one checkbox is checked in a row, i want to disable others. how can i do this ?

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      Use DataBindings property. Best regards, Alexey.

      L 1 Reply Last reply
      0
      • L Lost User

        hi all, i have 16 checkboxes in a form. (4 in a row and total 4 rows = 4x4) if any one checkbox is checked in a row, i want to disable others. how can i do this ?

        M Offline
        M Offline
        mav northwind
        wrote on last edited by
        #3

        Hi! Nothing magic about it: Just set the Enabled property of the CheckBoxes you want disabled to false. Regards, mav -- Black holes are the places where god divided by 0...

        1 Reply Last reply
        0
        • A alexey N

          Use DataBindings property. Best regards, Alexey.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          how do i use databindings for checkbox1, checkbox2, checkbox3, checkbox4 ? (if one is checked, then others must be disabled.) would you please write a simple code for this ?

          A 1 Reply Last reply
          0
          • L Lost User

            how do i use databindings for checkbox1, checkbox2, checkbox3, checkbox4 ? (if one is checked, then others must be disabled.) would you please write a simple code for this ?

            A Offline
            A Offline
            alexey N
            wrote on last edited by
            #5

            Add this line to FormLoad event: checkbox2.DataBindings.Add(new Binding("Enabled", checkbox1, "Checked")); When checkBox1 is checked checkbox2 will be enabled, and when checkBox1 is unchecked checkbox2 will be disabled. Best regards, Alexey.

            1 Reply Last reply
            0
            • L Lost User

              hi all, i have 16 checkboxes in a form. (4 in a row and total 4 rows = 4x4) if any one checkbox is checked in a row, i want to disable others. how can i do this ?

              M Offline
              M Offline
              maryamf
              wrote on last edited by
              #6

              i think this could be worked CheckBox[] ch1 = new CheckBox[] { checkBox1, checkBox2, checkBox3, checkBox4 }; { for (int x = 0; x < 4; x++) if (ch1[x].Checked) { foreach (CheckBox ch in ch1) { if (ch.CheckState == CheckState.Unchecked) ch.Enabled = false; } } }

              1 Reply Last reply
              0
              • L Lost User

                hi all, i have 16 checkboxes in a form. (4 in a row and total 4 rows = 4x4) if any one checkbox is checked in a row, i want to disable others. how can i do this ?

                E Offline
                E Offline
                engsrini
                wrote on last edited by
                #7

                Nothing hard to do the above things.... just put all the check boxes in a group box.. it will take care of enabling/disabling the states

                1 Reply Last reply
                0
                • L Lost User

                  hi all, i have 16 checkboxes in a form. (4 in a row and total 4 rows = 4x4) if any one checkbox is checked in a row, i want to disable others. how can i do this ?

                  R Offline
                  R Offline
                  Roy Heil
                  wrote on last edited by
                  #8

                  The best way of doing this is to use radio buttons instead of checkboxes. That is what radio buttons are for. Roy.

                  E 1 Reply Last reply
                  0
                  • R Roy Heil

                    The best way of doing this is to use radio buttons instead of checkboxes. That is what radio buttons are for. Roy.

                    E Offline
                    E Offline
                    engsrini
                    wrote on last edited by
                    #9

                    Sorry Roy is right... put radio buttons inside Group Box

                    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