[2005] Listview Group header click event?
I have a listview that is displayed in details views. I want to be able to select all items in a group if the group header is clicked/double-clicked but I can't figure out how to deterimine that a heasder has been clicked. Any ideas?
BTW, I want the group header not the column header.
Re: [2005] Listview Group header click event?
There is an example at http://msdn2.microsoft.com/en-us/lib...ps(vs.80).aspx which demonstrates something a bit different, but it does show how to deal with groups in events. Hope this might help.
Re: [2005] Listview Group header click event?
Thanks Bullbog
I actually used that example to make a sortable listview and was trying to increase the functionality to include the header selection. I'll look into it a litle further if I get a chance.
Re: [2005] Listview Group header click event?
I did it the lazy way: using a contextmenu. This allows me to select any item in the group or the group header.
vb Code:
Private Sub SelectGroupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectGroupToolStripMenuItem.Click
For Each item As ListViewItem In ListViewFiles.Items
If item.Group.Header = ListViewFiles.FocusedItem.Group.Header Then
item.Checked = True
End If
Next
End Sub
Re: [2005] Listview Group header click event?
I had to add this code to handle the case when more than one group exists.
vb Code:
Private Sub ListViewFiles_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListViewFiles.MouseDown
Dim inc As Integer = 0
Dim selection As ListViewItem = Nothing
While selection Is Nothing
selection = ListViewFiles.GetItemAt(e.X, e.Y + inc)
inc += 1
End While
selection.Focused = True
End Sub