From Clomosy Docs
Radio buttons, also called option buttons, present a set of mutually exclusive choices. You can create individual radio buttons using TClRadioButton. A selected radio button is displayed as a circle filled in the middle. When not selected, the radio button shows an empty circle.
AddNewRadioButton(TComponent, xName, xCaption): TclRadioButton
TComponent : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.
xName : The name of the defined radio button should be written.
xCaption : You can add a title.
| Feature | Use of | Definition |
|---|---|---|
| TclRadioButton | RadioButton1 : TclRadioButton; | A variable belonging to the TclRadioButton class is created. |
| AddNewRadioButton | RadioButton1 = MyForm.AddNewRadioButton(MyForm,'RadioButton1','Test Radio Button Caption'); | A new TclRadioButton is added to the form. |
| Width | RadioButton1.Width = 150; | Allows adjusting the width of the radioButton. |
| Height | RadioButton1.Height = 50; | Allows adjusting the height of the radioButton. |
| Align | RadioButton1.Align = alTop; | With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the page to learn about these features. |
| Margins | RadioButton1.Margins.Left = 50; // Right, Top, Bottom | With the Margins parameter, you can give margins at any scale from the right, left, bottom, top. |
| Text | RadioButton1.Text = 'RaidoButton's Text'; | It represents the text within the component. The text entered by the user or set by the program is managed through this property. |
| TextSettings | RadioButton1.StyledSettings = ssFamily; RadioButton1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c'); RadioButton1.TextSettings.Font.Size = 20; RadioButton1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline] |
Text formatting is performed in the component. To see the usage, see page. |
| isChecked | RadioButton1.isChecked = True; | Assign the value True or False to the Checked property to change the radio button's visual state. As soon as it is correct, it will come selected. |
Example:
Example let's put 2 radioButtons on the form. Here, when one is clicked and I click on the other, we will see that the clicked one is unticked. Now you can create a project with the options you want in the design you want with the radioButton.
- TRObject Syntax
var
MyForm:TclForm;
testButton : TclButton;
testRadio,testRadio2 : TClRadioButton;
void ButtonClicked;
{
testRadio.isChecked = not testRadio.isChecked;
}
{
MyForm = TclForm.Create(Self);
testButton= MyForm.AddNewButton(MyForm,'testButton','Click');
testButton.TextSettings.Font.Size=50;
testButton.Align = alCenter;
testButton.Height = 50;
testButton.Width = 100;
testRadio = MyForm.AddNewRadioButton(MyForm,'testRadio','Female');
testRadio.StyledSettings = ssFamily;
testRadio.TextSettings.Font.Size=25;
testRadio.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
testRadio.Align = alTop;
testRadio.Height = 30;
testRadio2 = MyForm.AddNewRadioButton(MyForm,'testRadio2','Male');
testRadio2.StyledSettings = ssFamily;
testRadio2.TextSettings.Font.Size=25;
testRadio2.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
testRadio2.Align = alTop;
testRadio2.Height = 30;
MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
MyForm.Run;
}
- Base Syntax
var MyForm:TclForm; testButton : TclButton; testRadio,testRadio2 : TClRadioButton;
procedure ButtonClicked; begin testRadio.isChecked := not testRadio.isChecked; end;
begin MyForm := TclForm.Create(Self); testButton:= MyForm.AddNewButton(MyForm,'testButton','Click'); testButton.TextSettings.Font.Size:=50; testButton.Align := alCenter; testButton.Height := 50; testButton.Width := 100;
testRadio := MyForm.AddNewRadioButton(MyForm,'testRadio','Female'); testRadio.StyledSettings := ssFamily; testRadio.TextSettings.Font.Size:=25; testRadio.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c'); testRadio.Align := alTop; testRadio.Height := 30;
testRadio2 := MyForm.AddNewRadioButton(MyForm,'testRadio2','Male'); testRadio2.StyledSettings := ssFamily; testRadio2.TextSettings.Font.Size:=25; testRadio2.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c'); testRadio2.Align := alTop; testRadio2.Height := 30;
MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
MyForm.Run;
end;
