listview groupstate
-
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 IntegerDim 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
-
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 IntegerDim 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
-
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 IntegerDim 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
SendMessage(IntPtr hWnd, int msg, int wParam, int lParam)
, whenmsg = 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 = 65535End Enum
(source: ObjectListView[^]) So, here are the points you could try: - use
GrpId.Value
. This makes a big difference. IfGetGroupId
returns null, there is no point calling SendMessage. - make stateMask aGroupState
value, not a simple integer value, and give it a meaningful masking value (GroupState.LVGS_ALL
for example). - interpret the return value ofSendMessage
as aGroupState
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
-
SendMessage(IntPtr hWnd, int msg, int wParam, int lParam)
, whenmsg = 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 = 65535End Enum
(source: ObjectListView[^]) So, here are the points you could try: - use
GrpId.Value
. This makes a big difference. IfGetGroupId
returns null, there is no point calling SendMessage. - make stateMask aGroupState
value, not a simple integer value, and give it a meaningful masking value (GroupState.LVGS_ALL
for example). - interpret the return value ofSendMessage
as aGroupState
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
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
-
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