[ACCEPTED]-How to set two radiobuttons in one group and two in another group?-vcl
To quote from the trusted Delphi 5 help:
By 7 default, all radio buttons that are directly 6 contained in the same windowed control container, such 5 as a
TRadioGroup
orTPanel
, are grouped. For example, two 4 radio buttons on a form can be checked at 3 the same time only if they are contained 2 in separate containers, such as two different 1 group boxes.
Put two buttons on a panel, and the other 6 two on another panel. That way, they will 5 be treated as separate groupings. Change 4 the panel bevels to remove the edge, and 3 the four buttons won't look to the user 2 as if they are separated, if that's what 1 you'd like.
A RadioButton does not have a GroupIndex 9 Property, like the SpeedButton does.
It would 8 be much more easier if it had, because you 7 could use numbers to create sets of RadioButtons 6 that interacts only with the ones of the 5 same number set in the GroupIndex.
So all 4 you can do is to out them inside a grouping 3 control, like a Panel.
But you always could 2 build your own version of a RadionButton 1 with different new properties. :)
This is why we use Groupbox and Radiogroups 6 (Can be found at standard controls). I recommend 5 you to create 2 Groupboxes and put 2 radiobuttons 4 in each one. Then you will be able to check 3 2 radiobuttons.
You can also choose a title 2 for the groupbox. This is a very nice way 1 to organise your application form
That is great when Radio buttons of same 22 group can be in rows or cols, but what if 21 radio buttons must be shown in an X style 20 (or in a more complex way):
A B
C D
Restrictions 19 for that X style sample i put:
- A has relation with D (A and D can not be checked at same time, checking one unchecks the other)
- C has relation with B (C and B can not be checked at same time, checking one unchecks the other)
It is visually 18 required as that, in an X style, so i can 17 not put any GroupBox that holds that RadioButton, since 16 GroupBox are rectangular, not diagonal.
I 15 do not know any fix only using standard 14 components, among there is a hack to make 13 panels visually transparent and also click 12 through able, so both panels are a square, one 11 over the other.
But what about having the 10 radio buttons very far one from the other,with 9 a lot of complex components, flow panels, memos, etc?
The 8 only option is to use third party components 7 (at last up to what i know) or to do a lot 6 of hard work:
- Create a panel for each RadioButton with exact same size and position as the RadioButton; this makes radio button to not uncheck any other, so more code is needed.
- Add code for each RadioButton, so when it is checked execute an uncheck on all the ones that are related with it (the ones that must not be checked at same time).
Too much work for something 5 that could had been implemented on a simple 4 property like RadioGroupIndex, if assigned 3 a value of 0 then work as they work now, else 2 uncheck only the ones for that same group... like 1 on main menus.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.