From Xojo Documentation

Revision as of 23:54, 27 January 2022 by Gperlman (talk | contribs) (Sample Code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Property (As Integer )
aControl.Index = newIntegerValue
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 " + index.ToString + "."
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