Jump to content

Problem with Listview


FireLord
 Share

Recommended Posts

randallc hit the nail on the head. The reason you're having trouble is because you're trying to set the data for a listview item, which means you're supposed to be using GUICtrlSetData() on a listview item. Instead, you're passing the handle to the listview itself into GUICtrlSetData() -- this has no meaning, as you don't set the data of a listview; you set the data for the listview item in the listview.

The only way you can modify a specific listivew item is if you store the handle for it (an array probably being the easiest way, as randallc has it) and run GUICtrlSetData() on the particular handle that you want. I'm not sure if randallc's example will work properly, though, as I believe GUICtrlSetData($nListViewItem, "Text") will wipe out the text for both columns and replace it with "Text" in the first column. If so, then you're going to have to use GUICtrlRead() on the target listview item, split the returned string using StringSplit(), replace the first item in the split array, join the array together again into a single string, then use GUICtrlSetData() on the control with the newly-formed text.

Using the GUIListView.au3 UDFs to set (sub)item text would probably make things easier.

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Link to comment
Share on other sites

randallc hit the nail on the head. The reason you're having trouble is because you're trying to set the data for a listview item, which means you're supposed to be using GUICtrlSetData() on a listview item. Instead, you're passing the handle to the listview itself into GUICtrlSetData() -- this has no meaning, as you don't set the data of a listview; you set the data for the listview item in the listview.

The only way you can modify a specific listivew item is if you store the handle for it (an array probably being the easiest way, as randallc has it) and run GUICtrlSetData() on the particular handle that you want. I'm not sure if randallc's example will work properly, though, as I believe GUICtrlSetData($nListViewItem, "Text") will wipe out the text for both columns and replace it with "Text" in the first column. If so, then you're going to have to use GUICtrlRead() on the target listview item, split the returned string using StringSplit(), replace the first item in the split array, join the array together again into a single string, then use GUICtrlSetData() on the control with the newly-formed text.

Using the GUIListView.au3 UDFs to set (sub)item text would probably make things easier.

Actually the reason why I was having trouble was because the items I was trying to copy were not from a listview but a listbox. I figured this out in this post: http://www.autoitscript.com/forum/index.php?showtopic=57692

Edited by FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

That doesn't actually explain this:

But as long as you've got the problem fixed, then good enough :P

Well not quite, I'm stuck on a little bug in some new code but if I can manage to get past it then I know it'll work.

What I'm trying to do is get all the items from the listbox and copy them into my listview.

If IsArray($buddiesSearch) Then
                        For $i = 1 To $buddiesSearch[0]
                            Send($buddiesSearch[$i] & "{Enter}"); Search for each individual player
                        Next
                        Sleep(500)
                        For $i = 0 To _GUICtrlListCount($ListBox) - 1
                            GUICtrlCreateListViewItem("|" &  _GUICtrlListGetText($ListBox, $i), $nListView)
                        Next

But anything after the second For loop does not work...

Edited by FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
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...