Board index » cppbuilder » How to get RadioButton in seperate containers to act as if one container

How to get RadioButton in seperate containers to act as if one container


2006-03-29 10:13:46 AM
cppbuilder39
I have several TRadioButtons, each is in its own panel. I need all the
buttons to act as if they are in the same group.
John.
 
 

Re:How to get RadioButton in seperate containers to act as if one container

John Grabner wrote:
Quote
I have several TRadioButtons, each is in its own panel. I need all the
buttons to act as if they are in the same group.
What is the reason that your program would behave different from all other
programs with radiobuttons ? Users will get confused by that.
You have to uncheck the other radiobuttons by some extra code.
void __fastcall TForm1::RadioButton5Click(TObject *Sender)
{
UncheckAllRadioButtonsExceptThisOne ( (TRadioButton*)Sender );
}
void __fastcall TForm1::UncheckAllRadioButtonsExceptThisOne ( TRadioButton *ThisRadioButton )
{
int nr = -1;
while ( ++nr < ComponentCount )
{
TRadioButton *RadioButton = dynamic_cast<TRadioButton*>(Components[nr]);
if ( RadioButton && RadioButton != ThisRadioButton )
RadioButton->Checked = false;
}
}
Hans.
 

Re:How to get RadioButton in seperate containers to act as if one container

John Grabner < XXXX@XXXXX.COM >wrote:
Quote
I have several TRadioButtons, each is in its own panel. I need all the
buttons to act as if they are in the same group.

John.
It all depends what you want to do. Which events you are using etc. I find Radio buttons difficult to use as some events do not act as expected. For example the OnClick event does not fire twice in succession for the same button. This is OK if you test the status separately, but very confusing and wrong IMHO if you want something to happen directly from the click.
George
 

{smallsort}

Re:How to get RadioButton in seperate containers to act as if one container

John Grabner < XXXX@XXXXX.COM >wrote:
Quote

I have several TRadioButtons, each is in its own panel. I
need all the buttons to act as if they are in the same group.
Then don't put them on seperate panels and use a TRadioGroup
instead.
~ JD