vb.net - Need To Remove Checkboxes From OwnerDrawn ListView But Still Keep Checkbox Functionality -
I have a custom made list view control that shows a list of notifications to the user. Basically, when a new notification arrives, a new entry has been added to the list view in bold. When the user reads the notification, it changes to regular font.
The only way I can work This was probably to use the checkbox to obtain (a read state) so a new notification should check its item and when it was read, Then it was unchecked. It works well and what I need, seems to get it.
However, I have a question ... In a way I can remove the picture of the check box, but still keep the functionality in the background. For example, do not draw checkboxes for list view items, but still to use ListView.Checkboxes = really be able and ListViewItem.Checked = true?
My ListView control is ownerdrawn and the code for my DrawItem event appears as:
Protected override sub OnDrawItem (eg DrawListViewItemEventArgs) E.State and ListViewItemStates.Selected) = 0 'Then there is a background draw for a selected item. E.Graphics.FillRectangle (System.Drawing.SystemBrushes.Highlight, e.bounds) e.DrawFocusRectangle () Other 'Draw backgrounds for an unselected item. E.Graphics.FillRectangle (System.Drawing.SystemBrushes.Control, e.Bounds) end then e.DrawBackground () e.DrawDefault = true MyBase.OnDrawItem (E) Catch Ex Exception MsgBox ("Exception Error:" as & Amp; east .message, MsgBoxStyle.Critical, "module: lsvOverdueCalls_DrawItem ()") try end end If I delete e.DrawDefault = true It removes the check box, but then I can not control the bold face font for a new notification. Thanks for any help
I created a new ListViewItem class Has eliminated ListViewItem and then a custom property. I then used my new class in my code referencing a ListViewItem across my code which allowed to add a new attribute named My Default ListViewItem.
Public class cust_ListViewItem inherited ListViewItem Private _read Boolean Private RegularFont as new font (Me.Font.FontFamily, Me.Font.size, FontStyle.Regular) as private BoldFont Read the new font in the form (Me.Font.FontFamily, Me.Font.size, FontStyle.Bold) Go back to the _read termination set as the Boolean (value as the Boolean) _read = value MarkAsRead () end set end Property private sub markAsRead () if _read then me.Font = regular fonts Else Me.Font = BoldFont End Sub End Class Then my new address To call the property, I used the following:
cust_ListViewItem = new cust_ListViewItem as Dim LVI if notifications (x) .read = true then lvi.Read = True ... However, I have also come to know that allows you to completely remove the checkboxes from different list view objects which I was initially trying to get o I just added the code to my custom listview class and The code is applied to each listview item.
Comments
Post a Comment