Segment.Selected
From Xojo Documentation
Property (As Boolean )
aSegment.Selected = newBooleanValue
or
BooleanValue = aSegment.Selected
New in 2019r2
Supported for all project types and targets.
or
BooleanValue = aSegment.Selected
New in 2019r2
Supported for all project types and targets.
True if the segment is selected.
Example
Using the SegmentedButton.SegmentAt method, you can get access to the properties on Segment. This code deselects all the segments and then selects the first one:
For i As Integer = 0 To SegmentedButton1.LastSegmentIndex
SegmentedButton1.SegmentAt(i).Selected = False
Next
SegmentedButton1.SegmentAt(0).Selected = True
SegmentedButton1.SegmentAt(i).Selected = False
Next
SegmentedButton1.SegmentAt(0).Selected = True
You access the segments of a SegmentedButton from the control’s SegmentedButton.SegmentAt method. 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 = SegmentedButton1.LastSegmentIndex DownTo 0
// get the reference to the segment
Var s As Segment = SegmentedButton1.SegmentAt(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 button knows to resizes its drawing boundaries or you can get weird effects
SegmentedButton1.ResizeSegmentsToFit
For i As Integer = SegmentedButton1.LastSegmentIndex DownTo 0
// get the reference to the segment
Var s As Segment = SegmentedButton1.SegmentAt(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 button knows to resizes its drawing boundaries or you can get weird effects
SegmentedButton1.ResizeSegmentsToFit