sonofalion Posted October 12, 2014 Posted October 12, 2014 Hi, is there a way to count how many times a specific string occurs within a listview? I would prefer it if it could be done by searching only a specific column, but if the latter is not feasible, it's still OK.
kylomas Posted October 12, 2014 Posted October 12, 2014 sonofalion, _GUICtrlListView_FindInText Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
sonofalion Posted October 12, 2014 Author Posted October 12, 2014 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.
Solution mikell Posted October 12, 2014 Solution Posted October 12, 2014 ? #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
sonofalion Posted October 12, 2014 Author Posted October 12, 2014 mikell, this looks great. Thank you!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now