Jump to content
Sign in to follow this  

ListView Help

Recommended Posts


So im trying to get the text of an item in a listview control, and I use this code:

MsgBox(0, "Test", _GUICtrlListView_GetSelectedIndices($VideoList)) ;//Returns 0 if the first item in the list view control is selected
  MsgBox(0, "Test", _GUICtrlListView_GetItemText($VideoList, 0)) ;// Returns the text of the first item in the list view control
  MsgBox(0, "Test", _GUICtrlListView_GetItemText($VideoList, _GUICtrlListView_GetSelectedIndices($VideoList))) ;// Returns nothing????

The last line returns nothing and I have no idea why?

Share this post

Link to post
Share on other sites

Hi, few ways to solve it..

If your Listview is created with autoit internal function GuiCtrlCreateListView() then you can do either or both of the following.

1) Get and use the handle of the GuiCtrlCreateListView() instead of passing a Control ID eg: $hVideoList = GUICtrlGetHandle($VideoList)

2) When passing _GUICtrlListView_GetSelectedIndices($VideoList) make it an Int value eg: Int(_GUICtrlListView_GetSelectedIndices($VideoList))

so your code could be:

$hVideoList = GUICtrlGetHandle($VideoList)
MsgBox(0, "Test", _GUICtrlListView_GetItemText($hVideoList, _GUICtrlListView_GetSelectedIndices($hVideoList)))
MsgBox(0, "Test", _GUICtrlListView_GetItemText($VideoList, Int(_GUICtrlListView_GetSelectedIndices($VideoList))))
$hVideoList = GUICtrlGetHandle($VideoList)
MsgBox(0, "Test", _GUICtrlListView_GetItemText($hVideoList, Int(_GUICtrlListView_GetSelectedIndices($hVideoList))))

Also if your using a multi select listview, then you could use _GUICtrlListView_GetNextItem() instead of _GUICtrlListView_GetSelectedIndices().

This way your sure to get an Int value.

With _GUICtrlListView_GetSelectedIndices() it can return a string of delimited Int values eg: eg: "0|1|2|3".. which is not a true Int.


Edited by smashly

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