Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Can radio button controls be resizable?
Is there any way to get a radio button control to have more or fewer entries by varying its properties? Or is always the size it is when it's first created?
Basically, I'm creating a form which may allow the user to select up to 5 choices. I prefer buttons to e.g. an edit list because the control is oriented horizontally and I'd like the choices to read left to right.
Basically, I'm creating a form which may allow the user to select up to 5 choices. I prefer buttons to e.g. an edit list because the control is oriented horizontally and I'd like the choices to read left to right.
Comments
In this there are four choices only but the radio button control has seven options. Upon the create of the window the even numbered options are made invisible.
I suspect you could do the same with your horizontal radio buttons. Create it in the form designer with all five options but upon create, hide the options that aren't applicable.
To refer to the individual options you use ctrlname.value
Eg: set_property(@Window:".RB_PERIOD.NULL", "VISIBLE", false$)
In your code, how are you telling it which options to turn off?
The control name is "RB_PERIOD" so
set_property(@Window:".RB_PERIOD", "VISIBLE", false$)
will hide the entire control but if you concatenate the, (and this is where I'm a bit sketchy because I can't remember), individual label or value to the control name, you are then referring to that option only.In my example I've concatenated "NULL" to the control name because I've labelled it "Null" but the value is also "Null" so I'm not sure which one OI is looking at.
So to refer to the individual option you use windowName.CtrlName.Label, all in uppercase
Damn, that would have been better.
To your point Don, I've been moving the radio button around already :-) - I shrink the form and expand it based on the number of rows and columns displayed, then determine where to place the radio button control if the option string is present, or I place an edit line there instead.
The radio control overall is OPTIONS, but the individual labels are still called RADIO_1, RADIO_2, etc. So I currently turn them all off, then turn some on based on how many options there are, e.g.:
SET_PROPERTY("OPTIONS.RADIO_1","VISIBLE",TRUE$)
SET_PROPERTY("OPTIONS.RADIO_1","TEXT","Commit")
SET_PROPERTY("OPTIONS.RADIO_2","VISIBLE",TRUE$)
SET_PROPERTY("OPTIONS.RADIO_2","TEXT","Place")
SET_PROPERTY("OPTIONS.RADIO_3","VISIBLE",FALSE$)
Now I can hammer at this, knowing that in principle it is possible to make a specific radio button control to turn on or off.
thanks
I do GOSUB DO_BUTTONS
DO_BUTTONS: * CURRENTLY UP TO 5 BUTTONS /* To refer To individual options IN radio button, windowName.CtrlName.Label */ Set_Property(OPTIONS,"VISIBLE",TRUE$) FOR I = 1 To 5 I_BUTTON = OPTIONS:".RADIO_":I OT = Field(OPTION_STRING,",",I) IF Len(OT) Then OT1 = OT[1,MAX_BUTTON_STRING_LENGTH$] Set_Property(I_BUTTON,"VALUE",OT1) Set_Property(I_BUTTON,"VISIBLE",TRUE$) End ELSE Set_Property(I_BUTTON,"VISIBLE",FALSE$) End NEXT I
But the control does not change its text.. I can verify that the labels are all radio_1, radio_2, etc.
Whilst you can change the text, the new text will only occupy the same space as the original text so if your new text is longer than the original, it will end up truncated.
Which is why you might need to programmatically increase the width of the radio group control.
This is where I'm stuck right now. I have modified the code to look like this:
FOR I = 1 To 5 I_BUTTON = OPTIONS:".RADIO_":I OT = Field(OPTION_STRING,",",I) IF Len(OT) Then OT1 = OT[1,MAX_BUTTON_STRING_LENGTH$] Set_Property(I_BUTTON,"TEXT",OT1) Set_Property(I_BUTTON,"VALUE",I) Set_Property(I_BUTTON,"VISIBLE",TRUE$) End ELSE Set_Property(I_BUTTON,"VISIBLE",FALSE$) End NEXT I
As you see, I'm modifying both the label shown as well as what is returned. Basically, I want to return a simple integer count 1, 2, etc. when the user selects the 1st, 2nd, etc. item in the radio button. However, the control refuses to change at all and stays stuck as displayed. It's confusing. Am I creating the right access string?
"MYWINDOWNAME.MYCTRLNAME.OPTIONS_1"
It's a little difficult to tell what it actually is based on your example.
What is the value of "OPTIONS" in your I_BUTTON assignment? It looks like OPTIONS may be your complete control name, which is fine but they you're referring to ".RADIO_":I instead of ".OPTIONS_":I.
As for setting the "VALUE" property, there's no need for that. Just assign it 1,2,3,4,5 in the form designer and retrieve the "VALUE" of the control itself.
Try this
Options = @Window:".OPTIONSRADIO" FOR I = 1 To 5 I_BUTTON = OPTIONS:".OPTIONS_":I OT = Field(OPTION_STRING,",",I) IF Len(OT) Then OT1 = OT[1,MAX_BUTTON_STRING_LENGTH$] Set_Property(I_BUTTON,"TEXT",OT1) // Set_Property(I_BUTTON,"VALUE",I) Set_Property(I_BUTTON,"VISIBLE",TRUE$) End ELSE Set_Property(I_BUTTON,"VISIBLE",FALSE$) End NEXT I