DesktopSegmentedButton.SegmentAt

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Property (As Segment )
aDesktopSegmentedButton.SegmentAt = newSegmentValue
or
SegmentValue = aDesktopSegmentedButton.SegmentAt

New in 2021r3

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 DesktopSegmentedButton.

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

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 " + SegmentedButton1.SegmentCount.ToString

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