Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CheckedListbox onDrawItem - how to render the checkbox
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
CheckedListbox onDrawItem - how to render the checkbox
Environment versions
Environment:
VB.NET 1.1
OS:
Windows Server 2012
Network:
Windows NT
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01595643
Message ID:
01595643
Views:
46
The method below belongs to a base class and gets fired alright.

Unfortunately I don't know how to render the checkbox in front of the item string.
   Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
        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
        Dim item = Items(index)
        Dim text As String
        text = If((item Is Nothing), "(null)", item.ToString())
        Using brush = New SolidBrush(e.ForeColor)
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit
            e.Graphics.DrawString(text, Me.Font, brush, e.Bounds)
        End Using
    End Sub

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Reply
Map
View

Click here to load this message in the networking platform