|
-
May 25th, 2007, 01:37 PM
#1
Thread Starter
Hyperactive Member
[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.
-
May 25th, 2007, 05:48 PM
#2
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.
-
May 29th, 2007, 05:00 AM
#3
Thread Starter
Hyperactive Member
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.
-
May 29th, 2007, 06:47 AM
#4
Thread Starter
Hyperactive Member
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
-
May 29th, 2007, 08:28 AM
#5
Thread Starter
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|