Results 1 to 5 of 5

Thread: [2005] Listview Group header click event?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    [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.

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    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:
    1. Private Sub SelectGroupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectGroupToolStripMenuItem.Click
    2.         For Each item As ListViewItem In ListViewFiles.Items
    3.             If item.Group.Header = ListViewFiles.FocusedItem.Group.Header Then
    4.                 item.Checked = True
    5.             End If
    6.         Next
    7.     End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    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:
    1. Private Sub ListViewFiles_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListViewFiles.MouseDown
    2.         Dim inc As Integer = 0
    3.         Dim selection As ListViewItem = Nothing
    4.  
    5.         While selection Is Nothing
    6.             selection = ListViewFiles.GetItemAt(e.X, e.Y + inc)
    7.             inc += 1
    8.         End While
    9.         selection.Focused = True
    10.     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
  •  



Click Here to Expand Forum to Full Width