Creating an Icon in a SegmentedControl

I’m trying to create an Icon in code to load into a 4 Button SegmentedControl that is showing up empty. I’m thinking I have to use the DrawInto Method but that is for a RectControl or do I have to make PBuffer a Graphic FileType. How do I with the code I got below.

  Dim iW, iH As Integer
   Dim PBuffer As Picture
  Dim IconColor, BorderColor As Color
  PBuffer = NewPicture(Width, Height, 32)

  For i As Integer = 0 To 3
    Select Case i
    Case 0
      iW = 23
      iH = 18
      PBuffer.Graphics.ForeColor =  IconColor
      PBuffer.Graphics.FillOval(0,0, iW, iH)
      
      PBuffer.Graphics.PenHeight = 0
      PBuffer.Graphics.PenWidth = 0
      PBuffer.Graphics.ForeColor = DarkTingeColor
      PBuffer.Graphics.DrawOval(0, 0, iW, iH-1)
    Case 1
      iW = 27
      iH = 22
      PBuffer.Graphics.ForeColor =  IconColor
      PBuffer.Graphics.FillRect(0, 0, iW, iH)
      
      PBuffer.Graphics.ForeColor = DarkTingeColor
      PBuffer.Graphics.DrawRect(0, 0, iW, iH-1)
    Case 2
      iW = 23
      iH = 18
      PBuffer.Graphics.PenHeight = 4
      PBuffer.Graphics.PenWidth = 4
      PBuffer.Graphics.ForeColor = BorderColor
      PBuffer.Graphics.DrawOval(0,0, iW, iH)
      PBuffer.Graphics.ForeColor = IconColor
      PBuffer.Graphics.FillOval(0,0, iW, iH)
    Case 3
      iW = 27
      iH = 22
     
      PBuffer.Graphics.PenHeight = 4
      PBuffer.Graphics.PenWidth = 4
      PBuffer.Graphics.ForeColor = BorderColor
      PBuffer.Graphics.DrawRect(0, 0, iW, iH)
      
      PBuffer.Graphics.ForeColor =  IconColor
      PBuffer.Graphics.FillRect(0, 0, iW, iH)
    End Select
    
    Dim s As SegmentedControlitem = SegmentedControl1.Items(i)
  
    s.Icon = PBuffer
  Next

Have you considered Sam’s “Retina Kit 3”?
I believe that allows one to include icons in segmented controls.

http://ohanaware.com/retinakit/

I need the created SegmentedControl icon to be a AlphaChannel .png graphic that will eventually draw into a canvas. So there is no code solution and a 3rd Party Class is the only way.

Try dropping a tiny canvas on it.

Thanks for the reply guys. I’ll try your suggestions. I have Retina Kit 1 and try that first.

Another approach could be to use a BevelButtons control set made into a grid. BevelButton has the icon property. Use the Value property to make it toggled.

The Bevel Button is another option I might try thanks Michel

[quote=268916:@Richard Summers]Have you considered Sam’s “Retina Kit 3”?
I believe that allows one to include icons in segmented controls.

http://ohanaware.com/retinakit/[/quote]
It does indeed, We use it all the time.