RadioButton

From Xojo Documentation

Revision as of 22:32, 15 February 2019 by PLefebvre (talk | contribs) (See Also)


For web apps, see RadioGroup.

Class (inherits from RectControl)

The standard radio button control used by desktop applications. RadioButtons are often placed within GroupBox controls.

Events
Action DropObject MouseExit
Closing GotFocus MouseMove
ConstructContextualMenu KeyDown MouseUp
ContextualMenuAction KeyUp MouseWheel
DragEnter LostFocus Opening
DragExit MouseDown
DragOver MouseEnter


Properties
Active fa-lock-32.png LockLeft TextSize
AllowAutoDeactivate LockRight Tooltip
AllowTabStop LockTop Top
Bold MouseCursor Transparent
Caption MouseX fa-lock-32.png TrueWindow fa-lock-32.png
Enabled MouseY fa-lock-32.png Underline
Handle fa-lock-32.png Name fa-lock-32.png Value
Height PanelIndex Visible
Index fa-lock-32.png Parent Width
Italic Scope fa-lock-32.png Window fa-lock-32.png
Left TabIndex
LockBottom TextFont


Methods
AcceptFileDrop AcceptTextDrop Invalidate
AcceptPictureDrop Close Refresh
AcceptRawDataDrop DrawInto SetFocus

Notes

If you enclose a group of radio button controls within a parent control (or just the parent window), other radio buttons are automatically deselected when the user clicks a radio button in the group.

If you have more than one group of radio buttons in a window, each group should have its own parent control. RadioButtons within a group will be enabled and disabled automatically when the parent control is enabled/disabled. You can use controls such as GroupBoxes, TabPanels, PagePanels, or even Canvases as parent controls.

If the Caption property contains an ampersand character, it will display only if it is preceded by another ampersand character. This is done to make applications on all platforms behave consistently.

Sample Code

Here's how to set up RadioButtons using a GroupBox.

Three RadioButtons are set up as a Control Set and are placed within a GroupBox.

In this code, the controls are all named "RadioButton1". RadioButton1's Action event is passed the parameter, "index As Integer". The parameter Index contains the value of Index for the RadioButton that was clicked. The event handler has this code:

Sub Action(index As Integer)
Label1.Text = "You chose radio button " + Str(index) + "."
End Sub

To select a RadioButton in a Control Set, you use its Index property in code to refer to the RadioButton whose value you want to set. For example, the following line selects the second RadioButton from code.

RadioButton1(1).Value = True

See Also

GroupBox, PagePanel, TabPanel controls