Sign in to follow this  
Followers 0
tittoproject

How to read the item's number in a List?

3 posts in this topic

#1 ·  Posted (edited)

I have a list made like that:

$list = GUICtrlCreateList("List", 10, 10, -1, 100)
GUICtrlSetData(-1, "Carlo|Carlo|Mario")

Normally I use the command GUICtrlRead($list) to read the selected item, but, as two or more items have the same value, I want to know also its order.

In the example, when I choose the value "Carlo", I want to know which "Carlo", the first or the second?

Edited by tittoproject

Share this post


Link to post
Share on other sites



maybe...

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $label, $button

GUICreate("ListBox Get Caret Index Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "Carlo|Carlo|Mario")
$button = GUICtrlCreateButton("Get Index", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            $ret = _GUICtrlListGetCaretIndex ($listbox)
            GUICtrlSetData($label, "Item : " & $ret)
    EndSelect
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I have a list made like that:

$list = GUICtrlCreateList("List", 10, 10, -1, 100)
GUICtrlSetData(-1, "Carlo|Carlo|Mario")

Normally I use the command GUICtrlRead($list) to read the selected item, but, as two or more items have the same value, I want to know also its order.

In the example, when I choose the value "Carlo", I want to know which "Carlo", the first or the second?

take a look at _GUICtrlListGetSelItems and the _GUICtrlList* UDF functions in general.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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