SegmentedControlItem.Selected

From Xojo Documentation

Property (As Boolean )
aSegmentedControlItem.Selected = newBooleanValue
or
BooleanValue = aSegmentedControlItem.Selected

New in 2010r4

Supported for all project types and targets.

True if the segment is selected.

Example

Using the SegmentedControl.Items property, you can get access to the properties on SegmentedControlItem. This code deselects all the segments and then selects the first one:

For i As Integer = 0 To SegmentedControl1.Items.Ubound
SegmentedControl1.Items(i).Selected = False
Next
SegmentedControl1.Items(0).Selected = True

You access the segments of a SegmentedControl from the control’s Items() property. It requires a parameter that specifies the segment that you want to address. In this example, the following code selects all the segments in a loop. For each segment, it uses the Selected property to determine whether the segment is selected.

// count down to avoid re-evaluating the Ubound all the time
For i As Integer = SegmentedControl1.Items.Ubound DownTo 0

// get the reference to the segment
Dim s As SegmentedControlItem = SegmentedControl1.Items(i)

// see if the segment was selected
If s.Selected Then
// it is selected so increase this segment in size
s.Width = s.Width + 2
End If
Next

// make sure the segmented control knows to resizes its drawing boundaries or you can get weird effects
SegmentedControl1.SizeToFit

See Also

SegmentedControl.