Sign in to follow this  
Followers 0
Scrubby

Cannot select an item in a listbox made in AutoIT

3 posts in this topic

Hi All,

I'm rather perplexed here. I created a listbox in my GUI using the following line of code

$listview = GUICtrlCreateListView ("Control |Name|Text|Control ID|In Rep|Check|Set",10,70,380, 220)

I added two buttons to the gui that moves the data up and down in the Listview, basically so the user can change the order of the items listed in the list view. Here's the code that performs that step, it works great!

Case $msg = $CtrlUpBtn

$Temp = GUICtrlRead(GUICtrlRead($listview) - 1, 2)

If StringInStr($Temp, "|") <> 0 Then

GUICtrlSetData(GUICtrlRead($listView) - 1, GUICtrlRead(GUICtrlRead($listview), 2))

GUICtrlSetData(GUICtrlRead($listView), $Temp)

Else

Msgbox(0, "Cannot Move!", "Control is already at the top!")

EndIf

However when I press the Up button, I'd like the selected item to follow the item that was switched, instead, the selected item remains where it is, so I found the following UDF function that looks like it should do the trick for me, however, it doesn't work, I've tried the hwnd, the control id, it just blows past this line of code, doesn't generate an error and nothing on the screen happens. Any clue out there if I'm missing something?

$test = _GUICtrlListSelectIndex ( $test, GUICtrlRead($listView) - 1 )

I even tried to automate it using the ControlCommand function and that didn't work and the listbox function in the autolib library as well... anyone else have an idea, or done this before successfully?

Scrubby

Share this post


Link to post
Share on other sites



Hi,

try

_GUICtrlListViewSetItemSelState ( $h_listview, $i_index [, $i_selected = 1 [, $i_focused = 0 ]] )

randall

That worked beautifully, thank you very much! :)

Scrubby

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  
Followers 0