Jump to content

ListView in a Tab


Anas
 Share

Recommended Posts

Hi,

I've a problem and a few questions about list view.

When I expand/collapse a group that causes the list view to add/remove a scrolling bar, the list view contents disappears and minimizing/restoring the window fix it.

- How can I fix the list view content disappearing without removing $LVS_EX_FULLROWSELECT.

 

Also, How can I:
- expand a collapsed group without applying $LVGS_NORMAL and $LVGS_COLLAPSIBLE separately (without calling  _GUICtrlListView_SetGroupInfo twice)
- remove the empty space at the end of the list view when scrolled to the end.
- place the groups expand arrow on the left side.

 

Thanks.

#include <GuiListView.au3>
#include <GUIConstants.au3>

Example()

Func Example()
    GUICreate("ListView in a Tab", 400, 250)
    GUICtrlCreateTab(1, 1, 400, 200)
    GUICtrlCreateTabItem('Tab')
    $LV = GUICtrlCreateListView("Column", 15, 35, 370, 150)
    ;$LV = GUICtrlCreateListView("Column", 15, 35, 370, 150, Default, $WS_EX_CLIENTEDGE) ;Works, $LVS_EX_FULLROWSELECT removed.
    $BT1 = GUICtrlCreateButton("Expand 1", 50, 210, 100, 30)
    $BT2 = GUICtrlCreateButton("Expand 2", 250, 210, 100, 30)
    GUISetState()

    _GUICtrlListView_EnableGroupView($LV)
    _GUICtrlListView_InsertGroup($LV, -1, 1, "")
    _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, BitOR($LVGS_COLLAPSED, $LVGS_COLLAPSIBLE))
    For $i = 1 To 10
        GUICtrlCreateListViewItem("Item " & $i, $LV)
        ;_GUICtrlListView_AddItem($LV, "Item " & $i) ;Same problem
        _GUICtrlListView_SetItemGroupID($LV, $i-1, 1)
    Next

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $BT1
                _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, BitOR($LVGS_NORMAL, $LVGS_COLLAPSIBLE))
            Case $BT2
                _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_NORMAL)
                _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
EndFunc

 

Link to comment
Share on other sites

I can live without the rest, but this is a breaking problem

On 2/29/2016 at 1:13 PM, Anas said:

When I expand/collapse a group that causes the list view to add/remove a scrolling bar, the list view contents disappears and minimizing/restoring the window fix it.

- How can I fix the list view content disappearing without removing $LVS_EX_FULLROWSELECT.

Any idea how to overcome this?

Link to comment
Share on other sites

This is an issue with the tab control. Create a child window on top of the tab, and create the listview in the child window:

#include <GuiListView.au3>
#include <GUIConstants.au3>

Example()

Func Example()
  $hGui = GUICreate("ListView in a Tab", 500, 400)

  GUICtrlCreateTab(1, 1, 500, 300)
  GUICtrlCreateTabItem('Tab')
  GUICtrlCreateTabItem("") ; end tabitem definition
  GUISetState()

  $hChild = GUICreate( "", 400, 250, 20, 30, $WS_POPUP, $WS_EX_MDICHILD, $hGui )
  $LV = GUICtrlCreateListView("Column", 15, 35, 370, 150)
  $BT1 = GUICtrlCreateButton("Expand", 50, 210, 100, 30)
  $BT2 = GUICtrlCreateButton("Collapse", 250, 210, 100, 30)
  GUISetBkColor( 0xFFFFFF )
  GUISetState()

  _GUICtrlListView_EnableGroupView($LV)
  _GUICtrlListView_InsertGroup($LV, -1, 1, "")
  _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSED)
  _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)

  For $i = 1 To 10
    ;GUICtrlCreateListViewItem("Item " & $i, $LV)
    _GUICtrlListView_AddItem($LV, "Item " & $i) ;Same problem
    _GUICtrlListView_SetItemGroupID($LV, $i-1, 1)
  Next

  While 1
    $msg = GUIGetMsg()
    Switch $msg
      Case $BT1
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_NORMAL)
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)
      Case $BT2
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSED)
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
  GUIDelete()
EndFunc

 

Both AutoIt and MicroSoft documentation states that the $LVGS-flags must be applied one by one.

Empty space. This seems more to be an issue related to the scrollbar, than to the listview. If you press the End key to go to last row there is no empty space. It seems as if the height of the group header is added to the max value of the scroll bar. But I don't think you can just decrease the max value of the scroll bar. If the listview contains 10 groups which are all collapsed, the scroll bar must still be able to scroll to the last group. Search the internet. If you can find a solution implemented in another language, we can also implement it in AutoIt.

Expand arrow on the left side. I don't think we have an AutoIt solution. If you can find information about the issue or maybe even an implementation, we can also implement it in AutoIt.

If you are interested, you can take a look at this thread to see how to catch expand/collapse events from the group.

Link to comment
Share on other sites

Well, I already have a child GUI ... 7 of them actually (for nesting Tabs), this is going to be a mess, but if it's going to fix it...

I'll search for the rest and see if I find anything.

 

Thanks LarsJ.

Link to comment
Share on other sites

Link to comment
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
 Share

×
×
  • Create New...