Jump to content

Get number of Item in the column of ListView?


 Share

Recommended Posts

I create the ListView with 3 columns. Each Column has diffirent number of items. 

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

    Local $idListview

    GUICreate("ListView Get Item Text Array", 400, 300)

    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUICtrlCreateListViewItem("line4|data4", $idListview)
    GUICtrlCreateListViewItem("line5|", $idListview)

    GUISetState(@SW_SHOW)


    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()

I used _GUICtrlListView_GetItemCount but it dont get on each Column

:(:(:(

Link to comment
Share on other sites

This example should give you some ideas.

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Local $idListview

Local $hWin = GUICreate("ListView Get Item Text Array", 400, 300)

$idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
GUICtrlCreateListViewItem("line4|data4", $idListview)
GUICtrlCreateListViewItem("line5", $idListview)
For $y = 6 To 30
    GUICtrlCreateListViewItem("line" & $y, $idListview)
Next
GUISetState(@SW_SHOW)

Local $aArray[_GUICtrlListView_GetItemCount($idListview) + 1][_GUICtrlListView_GetColumnCount($idListview)]
For $i = 0 To UBound($aArray) - 2
    For $j = 0 To UBound($aArray, 2) - 1
        $aArray[$i + 1][$j] = _GUICtrlListView_GetItem($idListview, $i, $j)[3]
        If $aArray[$i + 1][$j] <> "" Then $aArray[0][$j] += 1
    Next
Next
_ArrayDisplay($aArray)

Local $hCtrl = ControlGetHandle($hWin, "", $idListview)
MsgBox($MB_SYSTEMMODAL, "Information", "Item count in Column#1 = " & $aArray[0][0] & @LF & _
        "Item count in Column#2 = " & $aArray[0][1] & @LF & _
        "Item count in Column#3 = " & $aArray[0][2], 0, $hCtrl)

_GUICtrlListView_Scroll($idListview, _GUICtrlListView_GetItemPositionX($idListview, 0), _GUICtrlListView_GetItemPositionY($idListview, $aArray[0][0] - 1))
MsgBox(0, "Wait", "View end of column 1", 0, $hCtrl)
_GUICtrlListView_Scroll($idListview, _GUICtrlListView_GetItemPositionX($idListview, 1), _GUICtrlListView_GetItemPositionY($idListview, $aArray[0][1] - 2))
MsgBox(0, "Wait", "View end of column 2", 0, $hCtrl)
_GUICtrlListView_Scroll($idListview, _GUICtrlListView_GetItemPositionX($idListview, 2), _GUICtrlListView_GetItemPositionY($idListview, $aArray[0][2] - 2))
MsgBox(0, "Wait", "View end of column 3", 0, $hCtrl)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

 

Link to comment
Share on other sites

@kylomas


At one stage I named the GUI window ($hWin) to use as the parent of MsgBox dialog.  This keeps the message box on top of the GUI.

I got side-tracked and became obsessed with "$idListview", which appears in a lot of the functions in the script.  Of course "$idListview" is an identifier (id).   But I needed a handle for the MsgBox parameter. So the focus on "$idListview" reached its logical conclusion.   Testing showed it worked, and I didn't think any more about it until your post.

Malkey

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...