1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Private Sub ListView1_DrawSubItem(sender As Object, e As DrawListViewSubItemEventArgs) Handles ListView1.DrawSubItem
Dim lstView As ListView = TryCast(sender, ListView)
Dim textAlignment As TextFormatFlags = GetTextAlignment(lstView, e.ColumnIndex)
Dim itemColor As Color = e.Item.ForeColor
If (e.Item.Selected AndAlso Not lvEditMode) Then
If ((e.ColumnIndex = 0) OrElse lstView.FullRowSelect) Then
Using Brush As New SolidBrush(Color.Blue)
e.Graphics.FillRectangle(Brush, e.Bounds)
End Using
End If
Else
e.DrawBackground()
End If
If (e.ColumnIndex = 0) Then
Dim state As CheckBoxState = If(e.Item.Checked, CheckBoxState.CheckedNormal, CheckBoxState.UncheckedNormal)
Dim glyphSize As Size = CheckBoxRenderer.GetGlyphSize(e.Graphics, state)
Dim checkPad As Integer = (e.Bounds.Height - glyphSize.Height) / 2
Dim pt As New Point(e.Bounds.X + 2, e.Bounds.Y + 2)
Dim rect As New Rectangle(pt, New Size(16, 16))
e.Graphics.DrawRectangle(New Pen(New SolidBrush(Color.Lime), 2), New Rectangle(rect.X, rect.Y + 1, rect.Width, rect.Height))
If state = CheckBoxState.CheckedNormal Then
rect.Inflate(-3, -3)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
e.Graphics.DrawLines(New Pen(New SolidBrush(Color.OrangeRed), 2), New Point() {New Point(rect.Left, rect.Bottom - rect.Height / 2), New Point(rect.Left + rect.Width / 3, rect.Bottom), New Point(rect.Right, rect.Top)})
e.Graphics.SmoothingMode = SmoothingMode.Default
rect.Inflate(+3, +3)
End If
TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, New Point(pt.X + 16, pt.Y + 10), itemColor, textAlignment)
Else
TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, e.Bounds, itemColor, textAlignment)
End If
End Sub |
Partager