SegmentedButton.SegmentAt
From Xojo Documentation
Property (As Segment )
aSegmentedButton.SegmentAt = newSegmentValue
or
SegmentValue = aSegmentedButton.SegmentAt
New in 2019r2
Supported for all project types and targets.
or
SegmentValue = aSegmentedButton.SegmentAt
New in 2019r2
Supported for all project types and targets.
Returns the Segment instance at the index requested.
Notes
Use this property to change the properties of each Segment in the SegmentedButton.
Sample Code
This code loops through all the segments and changes their Titles:
Var seg As Segment
For position As Integer = 0 To SegmentedButton1.LastSegmentIndex
seg = SegmentedButton1.SegmentAt(position)
seg.Title = position.ToString
Next
For position As Integer = 0 To SegmentedButton1.LastSegmentIndex
seg = SegmentedButton1.SegmentAt(position)
seg.Title = position.ToString
Next
This code adds a new segment and then resizes all the segments so that they are visible:
Var seg As New Segment
seg.Title = "Seg " + Str(SegmentedButton1.SegmentCount)
SegmentedButton1.AddSegment(seg)
// Resize all the segments
For i As Integer = 0 To SegmentedButton1.LastSegmentIndex
Var item As Segment = SegmentedButton1.SegmentAt(i)
item.Width = SegmentedButton1.Width / (SegmentedButton1.SegmentCount) - 2
Next
seg.Title = "Seg " + Str(SegmentedButton1.SegmentCount)
SegmentedButton1.AddSegment(seg)
// Resize all the segments
For i As Integer = 0 To SegmentedButton1.LastSegmentIndex
Var item As Segment = SegmentedButton1.SegmentAt(i)
item.Width = SegmentedButton1.Width / (SegmentedButton1.SegmentCount) - 2
Next