Jewtus Posted August 22, 2014 Share Posted August 22, 2014 I'm sure I'm missing something very obvious, but how do I make a list box that has two or more columns? This is what I have $Results = GUICtrlCreateList("", 8, 56, 209, 448) And I insert data GUICtrlSetData($Results,$parse) $parse is a list of results separated by a | How can I add a date column? Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted August 22, 2014 Moderators Solution Share Posted August 22, 2014 Jewtus,A multicolumn ListBox is not what you think - all it does is align the elements in columns like this:1 5 9 2 6 10 3 7 4 8If you want to have rows of associated elements then you need a ListView - which is a very different beast. 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...
Zedna Posted August 22, 2014 Share Posted August 22, 2014 Use ListView instead of ListBox control. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Jewtus Posted August 22, 2014 Author Share Posted August 22, 2014 Now if I could only figure out how to return the specific element I have highlighted.... _GUICtrlListView_GetItemText($FoundAccountBox,0,0) gets the column I want but it doesn't know which row I have selected... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 22, 2014 Moderators Share Posted August 22, 2014 Jewtus,In the same UDF you will find _GUICtrlListView_GetSelectedIndices - looking in the Help file is always worth a try. 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...
Jewtus Posted August 22, 2014 Author Share Posted August 22, 2014 (edited) Yup, that is what I have been doing, but this is the trouble I'm having: $Number = _GUICtrlListView_GetItemText($FoundAccountBox,_GUICtrlListView_GetSelectedIndices($FoundAccountBox,0),0) That doesn't seem to work, where $Number = _GUICtrlListView_GetItemText($FoundAccountBox,0,0) Gets me the first column first row value. _GUICtrlListView_GetSelectedIndices($FoundAccountBox,0) does get my the selected row, but it doesn't seem to execute when I have it in line (or even if I specify it as a variable first) I even tried to swap the index and subindex thinking maybe I was confused, and the weirdest part... _GUICtrlListView_GetItemText($FoundAccountBox,0,_GUICtrlListView_GetSelectedIndices($FoundAccountBox,0)) That kicks up row 1 and the highlighted row's column value Edited August 22, 2014 by Jewtus Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 22, 2014 Moderators Share Posted August 22, 2014 Jewtus,<sigh>What does the Help file say is returned by ,_GUICtrlListView_GetSelectedIndices? Can you use it directly as a parameter in another functions? Answers:- 1. An array.- 2. No.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...
BrewManNH Posted August 22, 2014 Share Posted August 22, 2014 You'd probably want to use _GUICtrlListView_GetItemTextString to get all the columns of the row instead of just the first item in the row and then have to loop through the columns one at a time. Jewtus 1 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...
Jewtus Posted August 22, 2014 Author Share Posted August 22, 2014 Jewtus, <sigh> What does the Help file say is returned by ,_GUICtrlListView_GetSelectedIndices? Can you use it directly as a parameter in another functions? Answers: - 1. An array. - 2. No. M23 Yes, I did read that it returns an array, which is why I originally put _ArrayDisplay($Number2) when I was testing it. The array is never displayed, however I also had this line: MsgBox(0,"",$Number&@CRLF&$Number2) and the number2 does show the selected row value. That is when I tried swapping the index and subindex and got the column corresponding to the row I had highlighted. That is what has me so confused.... Link to comment Share on other sites More sharing options...
Jewtus Posted August 22, 2014 Author Share Posted August 22, 2014 You'd probably want to use _GUICtrlListView_GetItemTextString to get all the columns of the row instead of just the first item in the row and then have to loop through the columns one at a time. That is what I needed... This worked for me: $test= StringSplit(_GUICtrlListView_GetItemTextString($FoundAccountBox),"|",2)[0] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 22, 2014 Moderators Share Posted August 22, 2014 Jewtus,I see now you are using this code (why do people not space their code rather than cramping it together? ):_GUICtrlListView_GetSelectedIndices($FoundAccountBox,0)0 is interpreted as False - so you are actually getting a delimited string which explains why you do not get an array. You still need to extract the index from the string. I would stick with the array and just use the [1] element. 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...
BrewManNH Posted August 22, 2014 Share Posted August 22, 2014 If you only want one item selected at a time, create the ListView with $LVS_SINGLESEL as one of the styles for the LV, if you're using the default style settings for the LV then that value is always applied. This way you can use _GUICtrlListView_GetSelectedIndices with the $bArray parameter set to 0 and you will only get a single item's index number. No stringsplitting needed that way. 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...
Jewtus Posted August 27, 2014 Author Share Posted August 27, 2014 If you only want one item selected at a time, create the ListView with $LVS_SINGLESEL as one of the styles for the LV, if you're using the default style settings for the LV then that value is always applied. This way you can use _GUICtrlListView_GetSelectedIndices with the $bArray parameter set to 0 and you will only get a single item's index number. No stringsplitting needed that way. I tried this and even wit LVS_SINGLESEL, when I use _GUICtrlListView_GetSelectedIndices, I still get a | delimited string. This is what I tried: $Results = GUICtrlCreateListView("", 8, 58, 209, 448,$LVS_SINGLESEL) and MsgBox(0,"",_GUICtrlListView_GetItemTextString($Results,0)) I do have it working with the string split though so I think this topic can be closed. Thanks fellas! Link to comment Share on other sites More sharing options...
BrewManNH Posted August 27, 2014 Share Posted August 27, 2014 You misread what I wrote, I didn't say use _GUICtrlListView_GetItemTextString, I said use _GUICtrlListView_GetSelectedIndices with the $bArray parameter set to 0 to get the index number of the selected item. 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...
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