Control.Index

From Xojo Documentation

Property (As Integer )
aControl.Index = newIntegerValue
or
IntegerValue = aControl.Index

Supported for all project types and targets.

If the control is used in a control set, this specifies the control's index in the set.

Sample Code

The control set is often used to manage a group of RadioButtons since a single RadioButton in a window doesn't make much sense. Most typically, you create an instance of the RadioButton, assign 0 to its Index property, and then duplicate it. This increments the value of Index for each new instance but retain the original control's name.

To determine which RadioButton the user clicked, use the Action event handler of the control set. The parameter Index contains the value of Index for the RadioButton that was clicked. The event handler is this:

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

To set a RadioButton in a control set, you use its Index property 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 // 0-based

See Also

UserGuide:Desktop Control Sets, UserGuide:Web Control Sets topics