Discussion:
Dynamic Radiio Button Groups
(too old to reply)
JohnC
2008-08-06 11:31:18 UTC
Permalink
Back to dynamic construction of radio buttons in objects.
Well, I thought I had this working until I needed more than one instance of
the object on my form.
Then it turned out that all the radio buttons (in all instances of the
object) belonged to the same group.

Here is what I have:
TGroupBox* RadioButtonBox;
TRadioButton** RadioButtons;

RadioButtonBox = new TGroupBox(Parent); //Parent is passed into the
constructor as the form
RadioButtonBox->Parent = Parent;
// more details about the box

for(int i=0;i<NmbChips;i++)
{
RadioButtons[i] = new TRadioButton(Parent);
RadioButtons[i]->Parent = Parent;
// more details about the button
}

Things work fine if I only have one instance of the object.
However, if I have more than one instance, all buttons from all of the
instances get thrown into the same group.
I need the buttons in each instance to be a group unto themselves.

I have tried setting the button's parent to the box, but then the buttons
are not visible, so I don't know if that would work.
If I change the parent in the button's constructor to the box it makes no
difference.

How can I force these to be in separate groups??

Thanks for any help you can give,
John
JohnC
2008-08-06 14:27:57 UTC
Permalink
Got it!

It does work if you set the parent to the group box.
I had neglected to switch my radio button coordinates to relative
coordinates (relative to the group box).

Thanks,
John
Mike Ruskai
2008-08-06 15:10:49 UTC
Permalink
On or about Wed, 6 Aug 2008 09:27:57 -0500 did "JohnC"
Post by JohnC
Got it!
It does work if you set the parent to the group box.
I had neglected to switch my radio button coordinates to relative
coordinates (relative to the group box).
You can use any container control, so if you don't want the groupbox borders,
a borderless TPanel works just as well.

Loading...