Set state of Segmented Control in code

I have done enough reading and still can’t sort this out.

All my code is working fine except that I would like to be able to show that the button was pressed (ie. highlighted) even though it wasn’t actually pressed physically but other parts of the code dictate that it should LOOK like it was pressed.

This is the code in the Action Event of another button that “should” set the state. (btnExtentsOrScale) refers to the Segmented Control.

btnExtentsOrScale.Enabled=true btnExtentsOrScale.itemIndex=0 // should the set visual state?

The control and resulting code is working as expected, but it does not “look” like it, until a button is actually pressed.

[EDIT] I think I just repeated myself :slight_smile:

SegmentedControl1.Items(0).selected = True

Undocumented, for some reason.

<https://xojo.com/issue/46278>

1 Like

This looks documented to me:

http://documentation.xojo.com/index.php/SegmentedControl.Items
http://documentation.xojo.com/index.php/SegmentedControlItem

I did not look at the proper page, then. Never mind. Sorry.

Thanks Michel & Paul.

I did actually look at those two links before posting this. There is also this:
http://documentation.xojo.com/index.php/SegmentedControlItem.Selected

Nevertheless, on none of those pages do I see a CLEAR example of correct usage as posted by Michel.