littlebigman Posted October 4, 2010 Posted October 4, 2010 (edited) Hello I just need to display a two-column list of items with Name + Phone number and let the user select one or more items and click OK. I went through the samples in \Examples\Helpfile\, and it seems like the ListView object does the job but it's pretty complicated (_GUICtrlListView_CancelEditLabel.au3). I was wondering if I couldn't just use the basic ListBox object instead, use a TAB or some caracter to separate the two items, and use a regex to extract the phone number of all selected lines when the user clicks on OK? Not as pretty as a real grid, but it probably makes for easier code. If that sounds like a good idea, would someone have some code handy that I could check? Thank you. Edited October 4, 2010 by littlebigman
littlebigman Posted October 4, 2010 Author Posted October 4, 2010 Mmm... The app crashes when I add strings Global $arr[2] = ["John" + @TAB + "123", "Jane" + @TAB + "456"] ... $List1 = GUICtrlCreateList("", 8, 24, 241, 136, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) Local $i For $i = 0 to UBound($arr) - 1 ;CRASH: autoit3.exe has encountered a problem and needs to close. _GUICtrlListBox_AddString($List1, $arr[$i]) Next
littlebigman Posted October 4, 2010 Author Posted October 4, 2010 Turns out AutoIT doesn't allow "+" to concatenate strings, but rather "&": Global $arr[2] = ["John" & @TAB & "123", "Jane" & @TAB & "456"] However, the TAB character is ignored in the ListBox control, so the two "columns" are displayed with no space" between them. Does this control simply not allow this character, or is there some switch I should use when creating it?
Moderators Melba23 Posted October 4, 2010 Moderators Posted October 4, 2010 littlebigman, You cannot have columns in a List control, you need a ListView. But you do not necessarily need the ListView UDF, AutoIt has a native ListView control which you use like this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hLV = GUICtrlCreateListView("Col 1|Col2", 10, 10, 480, 300) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|SubItem " & $i, $hLV) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Please ask if you have any questions. M23 P.S. You can edit your posts to add detail - adding as many extra posts as you are at the moment is rather frowned on here. 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
littlebigman Posted October 4, 2010 Author Posted October 4, 2010 You cannot have columns in a List control, you need a ListView. But you do not necessarily need the ListView UDF, AutoIt has a native ListView control which you use like this: Thanks much for the code. I'll give it a shot.P.S. You can edit your posts to add detail - adding as many extra posts as you are at the moment is rather frowned on here. Right, but I do this on purpose: In case some other newbie looks in the archives months from now, it's easier to quickly find an answer if a thread only deals with a single problem
Moderators Melba23 Posted October 4, 2010 Moderators Posted October 4, 2010 littlebigman,It is not the number of topics, but the number of immediately successive individual posts within them - like the first 3 above. 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
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