Please consider my ondrawitem methods of my derived checkedListBox class. At this stage I put "-->" in front of he selected item and " " in front of the others. I would like to replace that with a checked box (square) and an empty box respectively, very much as in the oroginal control.
Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
MyBase.OnDrawItem(e)
Dim rectangle As RectangleF = e.Graphics.ClipBounds
Using brushBackground As New SolidBrush(Me.BackColor)
e.Graphics.FillRectangle(brushBackground, rectangle)
End Using
' e.DrawBackground()
'If e.State = DrawItemState.Focus Then
' e.DrawFocusRectangle()
'End If
Dim index = e.Index
If index < 0 OrElse index >= Items.Count Then
Return
End If
rectangle = e.Bounds
Using brush = New SolidBrush(Color.DarkBlue)
For i As Integer = 0 To Me.Items.Count - 1
Dim text As String = " " + Me.Items(i).ToString
If i = Me.SelectedIndex Then
text = "--> " + Me.Items(i).ToString
End If
rectangle.Y = i * rectangle.Height
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit
e.Graphics.DrawString(text, Me.Font, brush, rectangle)
Next
End Using
End Sub