From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
| This item was deprecated in version 2019r2.
Please use SegmentedButton.ResizeSegmentsToFit as a replacement.
Sizes the control to fit into its space, increasing or decreasing its width as necessary. Use this after making changes to the SegmentedControlItem width.
If you add a new segment, the SegmentedControl does not resize to fit it so you need to call SizeToFit:
Dim seg As New SegmentedControlItem
seg.Title = "Seg " + Str(SegmentedControl1.Items.Ubound + 1)
If you need to keep the SegmentedControl width the same then you will want to resize the individual segments to fit within the SegmentedControl width. Refer to the SegmentedControl.Items method for an example on how to do that.
This example demonstrates how to dynamically change a SegmentedControl's properties on the fly. For example, this code on a PushButton increases the size of the selected segment. The code cycles through all the segments and increases the size of each segment that is selected. The loop creates an instance of a SegmentedControlItem for each segment, tests whether it is selected using the Selected property, and then increases the width for only the selected ones. This will increase the overall width of the SegmentedControl:
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 + 10
// make sure the segmented control knows to resizes its drawing boundaries or you can get weird effects