Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. listview groupstate

listview groupstate

Scheduled Pinned Locked Moved Visual Basic
questionannouncementworkspace
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JR212
    wrote on last edited by
    #1

    Hi, How can I find the current state of a listviewgroup? What I found

    Public Function GetgroupColapseState(groep As Integer) As Boolean
    If Environment.OSVersion.Version.Major < 6 Then Return False
    Dim GrpId As System.Nullable(Of Integer) = GetGroupID(Me.Groups(groep))
    Dim statemask As Integer

      Dim nreturn As Integer = SendMessage(Handle, LVM\_GETGROUPSTATE, groep, statemask) 
    End Function
    

    is not working LVM_FIRST = &H1000 LVM_GETGROUPSTATE = (LVM_FIRST + 92) I want to not print the collapsed groups Jan

    J P 2 Replies Last reply
    0
    • J JR212

      Hi, How can I find the current state of a listviewgroup? What I found

      Public Function GetgroupColapseState(groep As Integer) As Boolean
      If Environment.OSVersion.Version.Major < 6 Then Return False
      Dim GrpId As System.Nullable(Of Integer) = GetGroupID(Me.Groups(groep))
      Dim statemask As Integer

        Dim nreturn As Integer = SendMessage(Handle, LVM\_GETGROUPSTATE, groep, statemask) 
      End Function
      

      is not working LVM_FIRST = &H1000 LVM_GETGROUPSTATE = (LVM_FIRST + 92) I want to not print the collapsed groups Jan

      J Offline
      J Offline
      JR212
      wrote on last edited by
      #2

      Hi, Is there nobody who can help. Are all programmergeniusses on holyday? Jan

      1 Reply Last reply
      0
      • J JR212

        Hi, How can I find the current state of a listviewgroup? What I found

        Public Function GetgroupColapseState(groep As Integer) As Boolean
        If Environment.OSVersion.Version.Major < 6 Then Return False
        Dim GrpId As System.Nullable(Of Integer) = GetGroupID(Me.Groups(groep))
        Dim statemask As Integer

          Dim nreturn As Integer = SendMessage(Handle, LVM\_GETGROUPSTATE, groep, statemask) 
        End Function
        

        is not working LVM_FIRST = &H1000 LVM_GETGROUPSTATE = (LVM_FIRST + 92) I want to not print the collapsed groups Jan

        P Offline
        P Offline
        phil o
        wrote on last edited by
        #3

        SendMessage(IntPtr hWnd, int msg, int wParam, int lParam), when msg = LVM_GETGROUPSTATE wil return a bit flag value expressing the group state of the group whose id = wParam. lParam contains a bit flag value expressing which group states are allowed. So, first is to get something useful for these bit flag values. This enum can help:

        <Flags()> _
        Public Enum GroupState

        ''' ''' The group is in normal state.
        '''
        LVGS_NORMAL = 0

        ''' ''' The group is collapsed.
        '''
        LVGS_COLLAPSED = 1

        ''' ''' The group is hidden.
        '''
        LVGS_HIDDEN = 2

        ''' ''' The group has no header.
        '''
        LVGS_NOHEADER = 4

        ''' ''' The group can be collapsed.
        '''
        LVGS_COLLAPSIBLE = 8

        ''' ''' The group has focus.
        '''
        LVGS_FOCUSED = 16

        ''' ''' The group is selected.
        '''
        LVGS_SELECTED = 32
        ''' ''' The group is subsetted.
        '''
        LVGS_SUBSETED = 64

        ''' ''' The subset link has focus.
        '''
        LVGS_SUBSETLINKFOCUSED = 128

        ''' ''' All states.
        '''
        LVGS_ALL = 65535

        End Enum

        (source: ObjectListView[^]) So, here are the points you could try: - use GrpId.Value. This makes a big difference. If GetGroupId returns null, there is no point calling SendMessage. - make stateMask a GroupState value, not a simple integer value, and give it a meaningful masking value (GroupState.LVGS_ALL for example). - interpret the return value of SendMessage as a GroupState value. In short:

        Dim stateMask As GroupState = GroupState.LVGS_ALL
        Dim GrpId As System.Nullable(Of Integer) = GetGroupID(Me.Groups(groep)
        Dim result As GroupState
        If (GrpId.HasValue)
        result = (GroupState)SendMessage(Handle, LVM_GETGROUPSTATE, GrpId.Value, (int)stateMask)
        End If

        "I'm neither for nor against, on the contrary." John Middle

        J 1 Reply Last reply
        0
        • P phil o

          SendMessage(IntPtr hWnd, int msg, int wParam, int lParam), when msg = LVM_GETGROUPSTATE wil return a bit flag value expressing the group state of the group whose id = wParam. lParam contains a bit flag value expressing which group states are allowed. So, first is to get something useful for these bit flag values. This enum can help:

          <Flags()> _
          Public Enum GroupState

          ''' ''' The group is in normal state.
          '''
          LVGS_NORMAL = 0

          ''' ''' The group is collapsed.
          '''
          LVGS_COLLAPSED = 1

          ''' ''' The group is hidden.
          '''
          LVGS_HIDDEN = 2

          ''' ''' The group has no header.
          '''
          LVGS_NOHEADER = 4

          ''' ''' The group can be collapsed.
          '''
          LVGS_COLLAPSIBLE = 8

          ''' ''' The group has focus.
          '''
          LVGS_FOCUSED = 16

          ''' ''' The group is selected.
          '''
          LVGS_SELECTED = 32
          ''' ''' The group is subsetted.
          '''
          LVGS_SUBSETED = 64

          ''' ''' The subset link has focus.
          '''
          LVGS_SUBSETLINKFOCUSED = 128

          ''' ''' All states.
          '''
          LVGS_ALL = 65535

          End Enum

          (source: ObjectListView[^]) So, here are the points you could try: - use GrpId.Value. This makes a big difference. If GetGroupId returns null, there is no point calling SendMessage. - make stateMask a GroupState value, not a simple integer value, and give it a meaningful masking value (GroupState.LVGS_ALL for example). - interpret the return value of SendMessage as a GroupState value. In short:

          Dim stateMask As GroupState = GroupState.LVGS_ALL
          Dim GrpId As System.Nullable(Of Integer) = GetGroupID(Me.Groups(groep)
          Dim result As GroupState
          If (GrpId.HasValue)
          result = (GroupState)SendMessage(Handle, LVM_GETGROUPSTATE, GrpId.Value, (int)stateMask)
          End If

          "I'm neither for nor against, on the contrary." John Middle

          J Offline
          J Offline
          JR212
          wrote on last edited by
          #4

          Thanks this is the working result

          Public Function GetgroupColapseState(ByVal lstvwgrp As ListViewGroup) As Boolean
            If Environment.OSVersion.Version.Major < 6 Then Return False
            Dim GrpId As System.Nullable(Of Integer) = GetGroupID(lstvwgrp)
            Dim stateMask As ListViewGroupState = ListViewGroupState.all
            If (GrpId.HasValue) Then
              Dim result As ListViewGroupState = SendMessage(Handle, LVM\_GETGROUPSTATE, GrpId.Value, stateMask)
              Return (result And ListViewGroupState.Collapsed) = ListViewGroupState.Collapsed
            End If
          End Function
          

          I wasn't giving as statemask happy again Jan

          P 1 Reply Last reply
          0
          • J JR212

            Thanks this is the working result

            Public Function GetgroupColapseState(ByVal lstvwgrp As ListViewGroup) As Boolean
              If Environment.OSVersion.Version.Major < 6 Then Return False
              Dim GrpId As System.Nullable(Of Integer) = GetGroupID(lstvwgrp)
              Dim stateMask As ListViewGroupState = ListViewGroupState.all
              If (GrpId.HasValue) Then
                Dim result As ListViewGroupState = SendMessage(Handle, LVM\_GETGROUPSTATE, GrpId.Value, stateMask)
                Return (result And ListViewGroupState.Collapsed) = ListViewGroupState.Collapsed
              End If
            End Function
            

            I wasn't giving as statemask happy again Jan

            P Offline
            P Offline
            phil o
            wrote on last edited by
            #5

            You are welcome.

            "I'm neither for nor against, on the contrary." John Middle

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups