jftuga Posted April 8, 2013 Share Posted April 8, 2013 $gui_lv = GUICtrlCreateListView("", 10, 30, 940, 250) _GUICtrlListView_AddColumn($gui_lv, "A",220) _GUICtrlListView_AddColumn($gui_lv, "B",200) _GUICtrlListView_AddColumn($gui_lv, "C",70) for $i = 1 to $data[0] $g_entry[$i] = GUICtrlCreateListViewItem($data[$i],$gui_lv) next GUICtrlCreateLabel("Choose:", 10, 10 ) $g_select_item = GUICtrlCreateButton("Select", 10, 290,100) $g_cancel = GUICtrlCreateButton("Cancel", 120,290,100) GUISetState() do $msg = GUIGetMsg() select case $msg = $GUI_EVENT_CLOSE exitloop case $msg = $g_cancel exitloop case $msg = $g_select_item MsgBox(0,"",GUICtrlRead($gui_lv) & @CRLF & GUICtrlGetState($gui_lv) ) ; always returns 4 and -1 endselect until $msg = $GUI_EVENT_CLOSE GUIDelete() I would like to have the row (or row number) returned when the "Select" button is pressed. However the MsgBox always returns 4 and -1. What am I doing wrong? Thanks, -John Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
BrewManNH Posted April 8, 2013 Share Posted April 8, 2013 Change the msgbox line to this and see if it works. MsgBox(0, "", _GUICtrlListView_GetSelectedIndices($gui_lv) & @CRLF & GUICtrlGetState($gui_lv)) ; always returns 4 and -1 Not sure what you're trying to get with the GUICtrlGetState part so I haven't touched that. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
kylomas Posted April 8, 2013 Share Posted April 8, 2013 (edited) jftuga, It's a lot easier to get help if you post runnable code. The following code builds on BrewmanNH's suggestion, see comments in code. expandcollapse popup; added the following to get the code to run #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> local $data[5] = [4,1,2,3,4] local $g_entry[ubound($data)] local $gui010 = guicreate('Test LV',510,350) ; end of code added to get the code to run $gui_lv = GUICtrlCreateListView("", 10, 30, 490, 250,$lvs_showselalways) ; will override single item selection _GUICtrlListView_AddColumn($gui_lv, "A", 220) _GUICtrlListView_AddColumn($gui_lv, "B", 200) _GUICtrlListView_AddColumn($gui_lv, "C", 70) For $i = 1 To $data[0] $g_entry[$i] = GUICtrlCreateListViewItem($data[$i], $gui_lv) Next GUICtrlCreateLabel("Choose:", 10, 10) $g_select_item = GUICtrlCreateButton("Select", 10, 290, 100) $g_cancel = GUICtrlCreateButton("Cancel", 120, 290, 100) GUISetState() Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $g_cancel ExitLoop Case $msg = $g_select_item ; use the following loop if allowing for multiple selections ($lvs_singlesel ovveridden) local $aSEL = _GUICtrlListView_GetSelectedIndices($gui_lv,true) for $1 = 1 to $aSEL[0] consolewrite('Item # ' & $aSEL[$1] & ' selected...value = ' & _GUICtrlListView_Getitemtextstring($gui_lv,$aSEL[$1]) & @lf) next ; the following can be used for the current item selected, or, 1ST item selected in a list of items consolewrite(_GUICtrlListView_Getitemtextstring($gui_lv,-1) & @lf) EndSelect Until $msg = $GUI_EVENT_CLOSE GUIDelete() kylomas Edited April 8, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jftuga Posted April 8, 2013 Author Share Posted April 8, 2013 @BrewManNH: Thank you! This is what I wanted. @kylomas: Thank you! Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now