Jump to content

Count string occurence in ListView


Go to solution Solved by mikell,

Recommended Posts

This will only return the item where the text is found, right? I am looking to perform a count, since the string I am looking for will be found in many items of the listview. I tried to build a function around _GUICtrlListView_FindInText that can do thi, but I failed miserably.

Link to comment
Share on other sites

  • Solution

?

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

GUICreate("ListView Get Column", 400, 300)
$idListview = GUICtrlCreateListView("col0|col1|col2", 2, 2, 394, 268)
_GUICtrlListView_SetColumnWidth($idListview, 0, 100)
GUISetState(@SW_SHOW)

GUICtrlCreateListViewItem("index 0|data1|more1", $idListview)
GUICtrlCreateListViewItem("index 1|data6|more2", $idListview)
GUICtrlCreateListViewItem("index 2|data3|more3", $idListview)
GUICtrlCreateListViewItem("index 3|data6|more4", $idListview)
GUICtrlCreateListViewItem("index 4|data5|more5", $idListview)
GUICtrlCreateListViewItem("index 4|data6|more6", $idListview)
GUICtrlCreateListViewItem("index 4|data7|more7", $idListview)

Local $txt = "", $search = "data6", $col = 1
For $i = 0 to _GUICtrlListView_GetItemCount($idListview)-1
   $txt &= _GUICtrlListView_GetItemText($idListview, $i, $col)
Next
StringReplace($txt, $search, "")
Msgbox(0,"", @extended & ' occurances of "' & $search & '" found in col ' & $col)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
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...