Segmented Control - Items(n).Visible = False

I notice the segmented control has an Items collection which allows access to the individual properties of the segmented control.

I have a segmented control with 3 segments, why can I not say SegmentedControl1.Items(0).Visible = False

Will I have to programmatically add and remove the segments to make them appear or not?

instead of visible = false, i set the enabled=false, text="" and width=0

I have this code to get round what I think your asking

  Dim s As SegmentedControlItem
    SegmentedControl1.Items(0).title=module1.LoadFile
  SegmentedControl1.Items(1).title=module1.SaveFile
  SegmentedControl1.items(2).title=module1.TestCode  
  For I As Integer =0 to SegmentedControl1.items.UBound
    s=SegmentedControl1.items(i)
    s.Selected =false
  next I

For i As Integer = SegmentedControl1.Items.Ubound DownTo 0 Dim s As SegmentedControlItem = SegmentedControl1.Items( i ) if i=3 THEN if dcount("OwnershipID","tblOwnership","")=1 then s.Enabled=false s.Title="" s.Width=0 end if END IF Next SegmentedControl1.SizeToFit

Hi NG P, how did u make the dotted box for the codes??

Used the “code” tag and separated the start and end


hello!

Let try this again… i was using the code thingy BUT the tag was around the code but without extra space.


For i As Integer = SegmentedControl1.Items.Ubound DownTo 0
    Dim s As SegmentedControlItem = SegmentedControl1.Items( i )
    if i=3 THEN
      if dcount("OwnershipID","tblOwnership","")=1 then
        s.Enabled=false
        s.Title=""
        s.Width=0
      end if
    END IF
  Next
  SegmentedControl1.SizeToFit
 For i As Integer = SegmentedControl1.Items.Ubound DownTo 0
    Dim s As SegmentedControlItem = SegmentedControl1.Items( i )
    if i=3 THEN
      if dcount("OwnershipID","tblOwnership","")=1 then
        s.Enabled=false
        s.Title=""
        s.Width=0
      end if
    END IF
  Next
  SegmentedControl1.SizeToFit

yeah… got it!!!

sorry for all the other attempt.

the previous code does not work anymore on the recent version of Xojo. Look at the other link.

https://forum.xojo.com/13713-segmented-controls-in-latest-beta