Jump to content

Recommended Posts

Posted

I am trying to find string in the list box ... working

trying to select it .. not working

atempting to get selected text ... not working

CODE
$ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input))

MsgBox(16,"position",$ret)

_GUICtrlListSetSel($listbox,1,$ret)

$ret = _GUICtrlListGetText ($listbox, _GUICtrlListSelectedIndex ($listbox))

MsgBox(16,"get text",$ret)

Posted (edited)

Here's what I would use:

Local $index = 0
For $i = 0 To _GUICtrlListCount($listbox)
    If $index = 0 Then
        If NOT StringInStr(_GUICtrlListGetText($listbox, $i), "String") = 0 Then $index = $i
    EndIf
Next
_GUICtrlListSetSel($listbox, 1, $index)
$text = _GUICtrlListGetText($listbox, $index)
Msgbox(0,"",$text)

Basically selects the first list item that contains the string.

Kurt

EDIT: Fixed Minor Mistake

Edited by _Kurt

Awaiting Diablo III..

Posted

My example posted above should work.

not working for me

would you mind to show me example beginning from this :

$ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input)) ; working

i want to return yhe index and select it

  • Moderators
Posted

not working for me

would you mind to show me example beginning from this :

$ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input)) ; working

i want to return yhe index and select it

Do yourself a favor, post a working example with a List control filled in, and show the text you want to find and select... and you'd probably get the answer that suits your needs. Don't make others go out of their way to help you by having to do that themselves.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Do yourself a favor, post a working example with a List control filled in, and show the text you want to find and select... and you'd probably get the answer that suits your needs. Don't make others go out of their way to help you by having to do that themselves.

I agree, form a simple example so we know exactly what you want.

Kurt

Awaiting Diablo III..

Posted

I agree, form a simple example so we know exactly what you want.

Kurt

Resolved ... I was too Lazy .. to understand ..

CODE
If (StringLen(GUICtrlRead($input)) > 0) Then

$ret = _GUICtrlListSelectString ($listbox, GUICtrlRead($input), 3)

If ($ret == $LB_ERR) Then

MsgBox(16, "Error", "Not Found")

Else

GUICtrlSetData($label, "Item #: " & $ret)

$ret = _GUICtrlListSelectedIndex ($listbox)

MsgBox(16, "index", $ret)

$ret = _GUICtrlListGetText ($listbox, _GUICtrlListSelectedIndex ($listbox))

MsgBox(16, "text", $ret)

EndIf

endif

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
×
×
  • Create New...