Jump to content
Sign in to follow this  
Leoj

Set selected list item

Recommended Posts

Leoj

Anyone got any ideas of how to set which list item is selected?

The only thing I see is [GUICtrlSetState] and [GUICtrlSetData] that could do anything like what I am suggesting. But both do not do what I need. They either overwrite the data or do not apply to a list view.

GUICtrlCreateList("Hello", 48, 80, 305, 150, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetData(-1, "Goodbye")

;;;and then a function that tells the GUI that 'Goodbye' should be selected no matter what else is in the list.

Func selectGoodbye()
     ;;;I have no idea how to make it select 'Goodbye'... but if I did it would go here.
EndFunc

Thanks if you spend any time reading or thinking about this =)

Share this post


Link to post
Share on other sites
smashly

Hi,

Have you looked in the AutoIt Help File under 'User Defined Functions -> GuiList Management' ?

There's a bunch of functions you can use to accomplish what your after.

Also you can use GuiCtrlSetData() like this to populate the list with values:

#include <GuiConstants.au3>

GUICreate('List', 400, 300, -1, -1, -1)
$List = GUICtrlCreateList('', 10, 10, 380, 280)
GUICtrlSetData(-1, "Hello|Goodbye|Google|Whatever", 'Whatever')
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select 
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Good Luck

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites
Leoj

I think I will be using: _GUICtrlListSelectString ... for anyone who may be looking for the same UDF.

Thanks much smashly, your becomming my best friend on these forums =).

Hope it works, I have to wait until I get home to try it.

Share this post


Link to post
Share on other sites
Davo

CODE

_GUICtrlListSelectIndex($listBoxHandle,_GUICtrlListFindString($listBoxHandle,$stringToSearchFor,$exactMatch=1or0))

Hope it helps.

Dave


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Share this post


Link to post
Share on other sites
Leoj

thanks davo, but I got it figured out :)

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  

×