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. RadioBoutton as a group

RadioBoutton as a group

Scheduled Pinned Locked Moved C#
help
7 Posts 5 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
    CodingLover
    wrote on last edited by
    #1

    Hi all, I have three radio buttons in a GroupBox. I want to find the selected radio button there. I've done the following. int _select; if(rb1.Checked) _select = 0; and so on. Seems it's not a good practice at all, say I have 10 radio buttons. Can someone suggest a better way to do this. Thanks

    I appreciate your help all the time... CodingLover :)

    C N 2 Replies Last reply
    0
    • C CodingLover

      Hi all, I have three radio buttons in a GroupBox. I want to find the selected radio button there. I've done the following. int _select; if(rb1.Checked) _select = 0; and so on. Seems it's not a good practice at all, say I have 10 radio buttons. Can someone suggest a better way to do this. Thanks

      I appreciate your help all the time... CodingLover :)

      C Offline
      C Offline
      Chintan Desai
      wrote on last edited by
      #2

      use RadioButton class as array and use ".Checked" accordingly with every radionbutton instance in a loop. e.g after creating array instance if(radioButton[i].Checked) _select=0;

      Thanks, Chintan(India)

      1 Reply Last reply
      0
      • C CodingLover

        Hi all, I have three radio buttons in a GroupBox. I want to find the selected radio button there. I've done the following. int _select; if(rb1.Checked) _select = 0; and so on. Seems it's not a good practice at all, say I have 10 radio buttons. Can someone suggest a better way to do this. Thanks

        I appreciate your help all the time... CodingLover :)

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        AFAIK, Windows forms don't have a RadioButtonList control. So I think there is no better way than what you are doing.

        Navaneeth How to use google | Ask smart questions

        C 1 Reply Last reply
        0
        • N N a v a n e e t h

          AFAIK, Windows forms don't have a RadioButtonList control. So I think there is no better way than what you are doing.

          Navaneeth How to use google | Ask smart questions

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

          How about that way that Chintan.Desai talking. I'll give a try and seems it's working fine.

          I appreciate your help all the time... CodingLover :)

          D N 2 Replies Last reply
          0
          • C CodingLover

            How about that way that Chintan.Desai talking. I'll give a try and seems it's working fine.

            I appreciate your help all the time... CodingLover :)

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            If the radiobuttons are in a groupbox, then use GroupBox.Controls property to loop through.

            C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void "Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding

            D 1 Reply Last reply
            0
            • C CodingLover

              How about that way that Chintan.Desai talking. I'll give a try and seems it's working fine.

              I appreciate your help all the time... CodingLover :)

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              That is OK. But AFAIK, you won't get design time support for control arrays in C#. You need to edit the designer generated code to make the radio buttons in an array or write your own code to add it to the form.

              Navaneeth How to use google | Ask smart questions

              1 Reply Last reply
              0
              • D dan sh

                If the radiobuttons are in a groupbox, then use GroupBox.Controls property to loop through.

                C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void "Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding

                D Offline
                D Offline
                Dan Neely
                wrote on last edited by
                #7

                using a panel can work where a groupbox isn't appropriate.

                Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall

                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