Jump to content

Set selected list item


Leoj
 Share

Recommended Posts

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 =)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!!!

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...