groupbox and radio buttons

  1. 4 months ago

    Hi All.

    Sorry for asking this stupid question, but I can't seem to figure something out even after reading through "Introduction to xojo".

    I have 3 radio buttons within a group box.

    I want to pop up a message box saying "You pressed radio button 1, 2, 3" thing, but I can't seem to find the right syntax.

    Can someone show me how to do this. I know the groupbox becomes a parent, but I just can't get it to work.


  2. Dave S

    Aug 9 San Diego, California USA

    inside the ACTION event , check the INDEX value, it will be associated with the radiobutton pushed

  3. Hi Dave.

    I'm really doing something stupid.

    I have my 3 radiobuttons within a Groupbox.

    In the action event for the radio buttons, just for now, I am asking it to print out the radiobutton1.index, and it throws this massive number : -21799xxx

    Under the radiobutton Action event, if I use Groupbox1.index I get the same thing

    If I use radiobutton1.value I get True or False.

    I'm confused.


  4. Dave S

    Aug 12 San Diego, California USA

    The action event should return an index variable

    ACTION(index as integer)
    msgbox "You pressed radiobutton #"+str(index)

    groupbox1.index is the index within a controlset (which you should be using) but if not, it does return that huge neg number (by design)

  5. Bob K

    Aug 12 Pre-Release Testers, Xojo Pro, Third Party Store Kansas City
    Edited 4 months ago

    Radiobuttons that are in a group box (or similar parent) act as a group. Implement the action event in each RadioButton and just use this code:

    Msgbox "This is radioButton <X>"

    Dave's reply was assuming your were creating Control Set (sometimes called a Control Array). In that case the index (of the control group) would be passed in via the Action event.

  6. Sascha S

    Aug 12 Pre-Release Testers, Xojo Pro Germany, Lower Saxony

    @Dave S Daves reply :) was meant to indicate he was using the wrong INDEX

    But if you are unfammiliar with the concept of Control Arrays, ... :)

    @Michael C you can add a RadioButton, give it a Name. Then add another RadioButton and give it the same Name, Xojo will ask if you want to create a Controll Array. Now you can Add more RadioButtons with the same Name and they will be added to your Control Array also.

    Now you have to deal with one Action Event for all Controls in the same Control Array. In this Action Event you have an index Property which tells you which Control in this Array has been used. Now @Dave S 's example will work.

  7. Norman P

    Aug 12 Pre-Release Testers, Xojo Pro under a bus

    radio buttons depend on their parenting to know which ones should act as a group of related radio buttons
    in a related set when you click one to enable it the others will disable
    and this has nothing to do with them being a control set

    if you have a control set of two radio buttons and a single radio button that is not part of the control set on a window all three behave as a single group of radio buttons
    click any one and the others will disable

    to make it so they act as independent groups you need to parent the ones you want to act as one set in a canvas or other control and the rest in something else

    and you could split a control set across those containers

  8. Sascha S

    Aug 12 Pre-Release Testers, Xojo Pro Germany, Lower Saxony
    Edited 4 months ago

    @Norman P and this has nothing to do with them being a control set

    And i always hoped this would be changed someday. :)

    But until then, we can achive this with our own code :)

  9. Norman P

    Aug 12 Pre-Release Testers, Xojo Pro under a bus

    why do in code what you can do just by putting them inside a canvas that is invisible ?

  10. Thanks all.

    This is beginning to come back to me. I worked with RealStudio for a long time, but been away longer. Now the light is beginning to come back on.

    Thanks for your help guys. Though I will probably have more questions.


or Sign Up to reply!