CGRemakes Posted December 1, 2010 Posted December 1, 2010 Is there an option or easy way to make it so people can hold down ctrl or shift to be able to select multiple items in a listview. I didn't see any flag or option, but I may have just overlooked it. I'm sure it's possible to program it (and I'm pretty sure I even know how), but I'm hoping the work has already been done for me. Thanks!
KaFu Posted December 1, 2010 Posted December 1, 2010 The listview default style is bitor($LVS_SHOWSELALWAYS, $LVS_SINGLESEL), where $LVS_SINGLESEL forces the selection of a single row only. Just set the style to $LVS_REPORT. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
CGRemakes Posted December 1, 2010 Author Posted December 1, 2010 The listview default style is bitor($LVS_SHOWSELALWAYS, $LVS_SINGLESEL), where $LVS_SINGLESEL forces the selection of a single row only. Just set the style to $LVS_REPORT.Excellent! I figured there must be something like that already written. No need to reinvent the wheel. Works like a charm.
nitekram Posted December 1, 2010 Posted December 1, 2010 (edited) You will also need another function, if you plan on doing anything with the list, as if you try to read the GuiCtrl it will only populate one of the listed items. #Include <GuiListBox.au3> _GUICtrlListBox_GetSelItems($hWnd) Edited December 1, 2010 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
CGRemakes Posted December 1, 2010 Author Posted December 1, 2010 (edited) You will also need another function, if you plan on doing anything with the list, as if you try to read the GuiCtrl it will only populate one of the listed items. #Include <GuiListBox.au3> _GUICtrlListBox_GetSelItems($hWnd) Thanks for the extra note, because I am having trouble accessing the selected information. What I'm trying to do is allow them to select from the list, and click on a button to export that information to a CSV file. I've looked at the extra information you pointed out, but I'm not sure how to use that in conjunction with a listview. I tried _GUICtrlListBox_GetSelItems and _GUICtrlListBox_GetSelItemsText, and I don't get information with it (maybe because I'm using a ListView, not a ListBox?). I'm trying to get the value of the entire row for each selected item. I also tried using _GUICtrlListView_GetSelectedIndices, and it does return the indicies of the selected items, but I'm not sure what to do with that information once I have it. I don't see a function that lets me select an entire row's information based on index. _GUICtrlListView_GetItem seems to just return the first column's value if I display the [3] element in the array of the returned information. Is there an easier way? EDIT: Think I got it figured out using _GUICtrlListView_GetSelectedIndices and _GUICtrlListView_GetItemTextString. Edited December 1, 2010 by CGRemakes
Zedna Posted December 1, 2010 Posted December 1, 2010 (edited) Look at LVS_EX_FULLROWSELECT #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 355, 226, 192, 114) $ListView1 = GUICtrlCreateListView("col1|col2|col3", 48, 16, 250, 150, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) $ListView1_0 = GUICtrlCreateListViewItem("a1|b1|c1", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("a2|b2|c2", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("a3|b3|c3", $ListView1) $Button1 = GUICtrlCreateButton("Button1", 136, 184, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(4160, "Information", "Selected Indices: " & _GUICtrlListView_GetSelectedIndices($ListView1)) EndSwitch WEnd Edited December 1, 2010 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
nitekram Posted December 2, 2010 Posted December 2, 2010 The above code works for getting the index, but not the string - use _GUICtrlListView_GetItemTextString, and then split the string into an array or what have you. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
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