Jump to content

How do you retrieve the index number of a selected item in a created list


Cheblon
 Share

Recommended Posts

I need to get the index number of a selected item in a list box. The list box is created by me and so for some reason the command ControlListView doesnt seem to work.

GUICtrlRead works but only returns the value in the list and not the index number of that item.

Any help is great, thanks.

Link to comment
Share on other sites

It worked but now it no longer responds to the list item changing.

I am using the method below to check for the item change:

while 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $lstSUname     
        MsgBox(0,"",_GUICtrlListView_GetSelectedIndices($lstSUname))
EndSwitch
WEnd

I am new to user functions so if there is another way of checking the item change please say

Thanks again

Link to comment
Share on other sites

It worked but now it no longer responds to the list item changing.

I am using the method below to check for the item change:

while 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $lstSUname     
        MsgBox(0,"",_GUICtrlListView_GetSelectedIndices($lstSUname))
EndSwitch
WEnd

I am new to user functions so if there is another way of checking the item change please say

Thanks again

If it's a list box you are using then look at the example in the help for

_GUICtrlListBox_GetSelItems

If it's a Listview then you have a parameter missing in _GUICtrlListView_GetSelectedIndices, see the help.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I am using a ListView. Is there a way to check when the selection has been changed?

Look at the example for _GUICtrlListView_Create(). Run this in Scite, if you don't have Scite, get it. Down at the bottom you will see message pop up everytime you click an item on the listivew. You can change that code to do whatever you want to.

Edit: Scite

Edited by Ichigo
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...