Sign in to follow this  
Followers 0
Fantastic

Listview grouping style

4 posts in this topic

Can we have the style as shown on the picture below with AutoIt?

The arrows which hide/show the grouped items.

post-50646-12716301702408_thumb.png

An example here:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

$Form2 = GUICreate("Example 2", 800, 600, -1, -1)
$hListView = GUICtrlCreateListView("", 12, 12, 500, 500)
; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 200)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)

_GUICtrlListView_EnableGroupView($hListView)
For $i = 1 To 10
    _GUICtrlListView_InsertGroup($hListView, -1, $i, $i)
    For $ii = 1 To 10
        $idx = _GUICtrlListView_AddItem($hListView, $i)
        _GUICtrlListView_AddSubItem($hListView, $idx, $ii, 1)
        _GUICtrlListView_SetItemGroupID($hListView, $idx, $i)
        ConsoleWrite($i & @TAB & $ii & @CRLF)
    Next
Next
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    Sleep(10)
WEnd

I had a topic for it in General Help and Support but I think it's more a GUI problem.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Check out the _GUICtrlListView_SetGroupInfo() function. It supports setting a "collapsible" state to groups, but only supported on Vista or higher.

I'm not sure if it creates the arrows you want, but it might be worth checking out.

untested:Tested on Win2k8. Collapsible groups designated by plus/minus toggle.

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

$Form2 = GUICreate("Example 2", 800, 600, -1, -1)
$hListView = GUICtrlCreateListView("", 12, 12, 500, 500)
; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 200)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)

_GUICtrlListView_EnableGroupView($hListView)
For $i = 1 To 10
    _GUICtrlListView_InsertGroup($hListView, -1, $i, $i)
    For $ii = 1 To 10
        $idx = _GUICtrlListView_AddItem($hListView, $i)
        _GUICtrlListView_AddSubItem($hListView, $idx, $ii, 1)
        _GUICtrlListView_SetItemGroupID($hListView, $idx, $i)
        _GuiCtrlListView_SetGroupInfo($hListView,$i,$idx,0,$LVGS_COLLAPSIBLE)
        ConsoleWrite($i & @TAB & $ii & @CRLF)
    Next
Next
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    Sleep(10)
WEnd

Edited by spudw2k

Share this post


Link to post
Share on other sites

Yes, it's a little misleading. The function itself requires Windows XP+, but in order to use the $iState param of that func...you must have Vista or higher.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0