I found the following code which does a good job of modifying the background colour of selected items. This is a listview with checkboxes highlighted so I want the colour bar to shift 20 to the right to clear the checkbox column, by adding 20 to the bounds it does the job, although it also shifts the subitems so that they are right of their columns. However, the checkbox for that line disappears. Any ideas about getting the checkbox back, I've looked through DrawListViewSubItemEventArgs and cannot see anything that will do it. How do I get the checkboxes back and also, can I leave the subitem columns where they should be without shifting them right?
Private Sub lsvFileList2_DrawSubItem(sender As Object, e As DrawListViewSubItemEventArgs) Handles lsvFileList2.DrawSubItem
Dim NewBounds As Rectangle
If e.Item.Selected = True Then
NewBounds = e.Bounds
NewBounds.X = e.Bounds.X + 20
e.Graphics.FillRectangle(New SolidBrush(Color.Purple), NewBounds)
TextRenderer.DrawText(e.Graphics, e.SubItem.Text, New Font(Me.Font, Nothing), New Point(e.Bounds.Left + 23, e.Bounds.Top + 2), Color.AntiqueWhite)
Else
e.DrawDefault = True
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire