Segmented Control workflow


While trying to have something like that on an web app in order to register a service Sample Here apparently I have some issues and no idea if it’s the control or an issue with the framework or the code and so on.

So I did added the Segmented Control and in the ActionEvent I added this

Select Case SegmentIndex Case 0 Me.Selected(0) = True Case 1 Me.Selected(0) = True Me.Selected(1) = True Case 2 Case 3 End Select

The segmented control is set for multiple select, but when I press on the tab 0 I get this error in the IDE

Case 0 Me.Selected(0) = True and the Exception that I get is “StackOverflowException” with no other details.

Any idea where this is coming from and how it supposed to work ?

I did saw as well a control called WebPageSource, this could be used for example to load all that css similar to the above page to it saves me from a lot of work ?

and how do you use that ? Unfortunately I don’t see that in the examples and the docs tell little bit about it.


The problem appears to occur when you’re attempting to set the selected status of the control that by clicking on it, you had just selected as true - it’s already flagged as true. I’m not sure why it would happen (theoretically it shouldn’t care, but it might have something to do with how it handles changing state), but in reality, there is no need to do Me.Selected(0) = true in the case of clicking the 0 position of a segmented control. There is no need to do that at all in the action event - the one you select will always be toggled to true. If you have multiple selectable set, each time you click on one, it will toggle itself either true or false; you don’t have to do that yourself so it would appear you’re kinda trying to overthink how it would set true/false on the status of each segment.

If you want to do something based upon which ones are selected, you’d test if each segment were true or false (so, for example: if Me.Selected(0) = True Then EndIf )

Hi Tony, well the idea was to do that automatically I guess, similar to the url form and progressively select them once the next button is pressed, then in some cases , once you press on a previous step to deselect the next ones and keep selected only the current one and the one before if there is any. So I guess in my case maybe I kind of used the wrong control and I could do that simply with some canvas draw or something.


Either that or consider what you’re trying to implement.

Let’s say you’re say I want to click on segment 0 - its already selected, but I want it to be the “active” segment, I don’t want to deselect it, but I would want to deselect segment 1 and 2 then you might do the following (small snippet out of a case and a very basic example):

Select Case SegmentIndex
Case 0
  if me.Selected(0) = False Then
    me.Selected(0) = True
  End If
  me.Selected(1) = False
  me.Selected(2) = False

This will guarantee that segment 0 is true, and will toggle 1 and 2 to false. This doesn’t cause a segment fault when I tested it.

The action event is raised when the segment is selected by the user or by code
Setting segment(0) to true when selected(0) is true is creating an endless loop, hence the stack overflow.
Look at your stack when you get the error.