I have a custom made listview control that shows a list of notifications to the user. Basically, when a new notification comes in, a new entry is added to the listview in Bold. When the user reads the notification, it turns to regular font.
The only way I could work out how to achieve this probably (a read status) was to use checkboxes. So a new notification would have its item checked and when it was read it was unchecked. This works well and seems to achieve what I need.
However, my question is....is there a way I can remove the drawing of the checkboxes but still keep the functionality in the background. So for example, not draw the checkbox for the listview item, but still be able to use ListView.Checkboxes = True and ListViewItem.Checked = True?
My ListView control is ownerdrawn and the code for my DrawItem event looks like so:
Protected Overrides Sub OnDrawItem(e As DrawListViewItemEventArgs)
Try
If Not (e.State And ListViewItemStates.Selected) = 0 Then
'Draw the background for a selected item.
e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Highlight, e.Bounds)
e.DrawFocusRectangle()
Else
'Draw the background for an unselected item.
e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, e.Bounds)
End If
e.DrawBackground()
e.DrawDefault = True
MyBase.OnDrawItem(e)
Catch ex As Exception
MsgBox("Exception Error: " & ex.Message, MsgBoxStyle.Critical, "Module: lsvOverdueCalls_DrawItem()")
End Try
End Sub
If I remove the e.DrawDefault = True
it removes the checkboxes, but then I can't control the bold face font for a new notification.
Any help appreciated. Thanks