SegmentedControl Problem

I am using Xojo for Mac 17.2

I add a SegmentedControl to a view and edit it to have 5 buttons
then through code i try to select which button is chosen using this:

SegmentedControl1.Item(0).Selected= true

(1 - 4) work but (0) doesnt

Is this a flaw or am I coding wrong?

You can use your SegmentedControl name .Value to get/set ones.

SegmentedControl1.Value

Also with Xojo you have iOS sample (example) called SegmentedControlExample under iOS - Control of Examples TAB under New Project Dialog.

Also you can use this as well (this is just example code)

Dim Ret As Boolean

’ Get Selected (True/False) value
Ret = Self.SegmentedControl1.Item(0).Selected

If Ret = True Then
System.DebugLog(“Item 0 is selected.”)
Else
System.DebugLog(“Item 0 is not selected.”)
End If

System.DebugLog will printout string expression in debug log of terminal/simulator which you can see/view from Simulator, menu DEBUG then Open System Log…

Hope it’s help.

[quote=351380:@Kevin Currie]SegmentedControl1.Item(0).Selected= true
:
Is this a flaw or am I coding wrong?[/quote]

I do it this way:

SegmentedControl1.Value = tabNumber

Thanks guys this does work

SegmentedControl1.Value = 0