MuffettsMan Posted April 16, 2015 Share Posted April 16, 2015 running the following code on a listview that has nothing selected: $selectedRow = _GUICtrlListView_GetSelectedIndices($GUI_BackupQueueListView) ; return the selected row ConsoleWriteGUI("$selectedRow ID: " & $selectedRow & @CRLF) $rowID = _GUICtrlListView_GetItemText($GUI_BackupQueueListView, Number($selectedRow), 0) $rowName = _GUICtrlListView_GetItemText($GUI_BackupQueueListView, Number($selectedRow), 1) ConsoleWriteGUI("ID: " & $rowID & " Name: " & $rowName & @CRLF) i was hoping it would error or something but it returns the first value in the list (which when the script loads nothing is selected) is there a way to distinguish if something is selected or not? Don't let that status fool you, I am no advanced memeber! Link to comment Share on other sites More sharing options...
MuffettsMan Posted April 16, 2015 Author Share Posted April 16, 2015 so basically, how can i tell if the first row is selected or no row is selected? Don't let that status fool you, I am no advanced memeber! Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted April 16, 2015 Moderators Solution Share Posted April 16, 2015 MuffettsMan,You need to check the returned value from the function. If using the default string return, you get an empty string if nothing is selected - if using the array return, the [0] element gives the count of selected items. This works fine for me: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Column", 10, 10, 200, 200) For $i = 0 To 9 GUICtrlCreateListViewItem("Item " & $i, $cLV) Next $cButton = GUICtrlCreateButton("Selected", 10, 300, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $sSel = _GUICtrlListView_GetSelectedIndices($cLV) MsgBox($MB_SYSTEMMODAL, "Selected", "-" & $sSel & "-") ; shows when return is an empty string $aSel = _GUICtrlListView_GetSelectedIndices($cLV, True) MsgBox($MB_SYSTEMMODAL, "Selected count", $aSel[0]) ; Shows count of selected items EndSwitch WEndAll this is clearly explained in the Help file. M23 MuffettsMan 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MuffettsMan Posted April 16, 2015 Author Share Posted April 16, 2015 (edited) Thx Melba, I think the definition of clearly starts to degrade when you don't know what you are doing - I must have jacked up when using Number($selectedRow) instead $selectedRow[0] like I should have been using looking at it now i don't know what i was thinking Edit: blaugh i think i get it... the code was doing what i said not what i meant.... when i did the number($var) of a null it prob just sets it to 0 - no where did i actually check to see if it was legit /sigh Edited April 16, 2015 by MuffettsMan Don't let that status fool you, I am no advanced memeber! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2015 Moderators Share Posted April 16, 2015 MuffettsMan, the code was doing what i said not what i meantYup, always annoying when the code refuses to read your mind and just executes exactly what you told it to do. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MuffettsMan Posted April 17, 2015 Author Share Posted April 17, 2015 autoit feature / enhancement request - mind reader UDF... aka the birth of skynet! Don't let that status fool you, I am no advanced memeber! 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