segmentedControl: setting the selected tab

Hi,

I have a WebSegmentedControl with three segments whose SelectionType is single. I would like to programmatically set the active segment to the first one, so I set it’s ListIndex property to 0 . . . but that doesn’t change anything: the previously active segment is still the active one.

What am I doing wrong ?

Thanks

Hi Gilles,

Use the Selected Cell property

MySegmentedControl.Selected(0) = True

http://developer.xojo.com/websegmentedcontrol

I realized I made a mistake in setting the ListIndex property of a WebListBox instead of the SegmentedControl, so .ListIndex = 0 works :-(.

But I tried @Roger St-Arneault suggestion, and it worked . . . except that the previously selected segment remained selected, event though SelectionStyle is set to Single. Can’t tell if it’s a bug or a feature ;-).

Merci et bonne journée Roger

Behaving as expected to match Desktop behavior. The Single-Selection option applies only to when the user is changing the selection. Setting it to multiple allows you to use a SegmentedControl for text formatting for example (Bold, Italic, Underline).

Thanks Tim for the explanation.

So you’ll have to set other tabs selected state to false…

MySegmentedControl.Selected(1) = False

Something like this might work. I wrote this in the post editor so it may need to be tweaked.

[code]Sub SelectTab(extends oSeg as WebSegmentedControl, iSelect as Integer)
dim iCount as Integer = oSeg.SegmentCount

for i as Integer = 0 to (iCount - 1)
oSeg.Selected(i) = (i = iSelect)

next

End Sub
[/code]