Link to home
Start Free TrialLog in
Avatar of Basicfarmer
BasicfarmerFlag for United States of America

asked on

Listview with gridlines and groups

Experts, I am using a listview on my form. I have it set to use gridlines. In design view the gridlines are there. But as the list is populated it creates groups in the listview to sort the items. When the groups are added the gridlines disappear. Is this just the way it works or is there something else i can do to show the gridlines with groups?
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Basicfarmer

ASKER

I did not get that it was well know but i have done quite a bit of searching for it and people continue to suggest making sure that gridlines is set to TRUE.
I give up. I cannot find anything definitively saying it does not work, but cannot find a solution either.
Have you looked into the OwnerDraw property? If you set it to True and hook up some events like this for example
    Private Sub ListView1_DrawSubItem(sender As Object, e As System.Windows.Forms.DrawListViewSubItemEventArgs) Handles ListView1.DrawSubItem
        With e.Graphics
            .DrawLines(New Pen(SystemColors.ButtonFace), New Point() {New Point(e.Bounds.Left, e.Bounds.Top - 1), New Point(e.Bounds.Left + e.Bounds.Width, e.Bounds.Top - 1), New Point(e.Bounds.Left + e.Bounds.Width, e.Bounds.Top + e.Bounds.Height), New Point(e.Bounds.Left, e.Bounds.Top + e.Bounds.Height)})
        End With
        e.DrawText()
    End Sub

    Private Sub ListView1_DrawColumnHeader(sender As Object, e As System.Windows.Forms.DrawListViewColumnHeaderEventArgs) Handles ListView1.DrawColumnHeader
        e.DrawDefault = True
    End Sub

Open in new window

it seems to come close to what you need.
User generated image
Robert, I am sorry that i gave up too soon and already posted points to another member. Thank you for posting this I will follow this lead...
No problem, see if you can get it to work for you and if so, we talk business ;-)