Azevedo Posted November 4, 2014 Share Posted November 4, 2014 Hi. Is it possible to change the order of items in a listBox by drag'n'drop them? By dragging an item, the mouse cursor changes (dragging). But it does nothing. Thanks!expandcollapse popup;http://brugbart.com/create-list-view-autoit #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) MainGUI() ; ----- GUIs Func MainGUI() Global $listview $listGUI = GUICreate("AutoIt list item GUI", 400, 200, 100, 200, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Main") $listview = GUICtrlCreateListView("Users", 10, 10, 200, 150) _GUICtrlListView_SetColumnWidth($listview, 0, 150) GUICtrlCreateListViewItem("First Item", $listview) GUICtrlCreateListViewItem("Second Item", $listview) GUICtrlCreateListViewItem("Third Item", $listview) $BtnAdd = GUICtrlCreateButton("Add Item", 10, 165, 80, 30) GUICtrlSetOnEvent(-1, "Addi") $BtnSelect = GUICtrlCreateButton("Select", 100, 165, 80, 30) GUICtrlSetOnEvent(-1, "SelectItem") GUISetState() While 1 Sleep(10) WEnd EndFunc ; ///// Functions Func Addi() $sToAdd = InputBox("Add", "Enter Item Name", "") GUICtrlCreateListViewItem($sToAdd, $listview) EndFunc Func SelectItem() $sItem = GUICtrlRead(GUICtrlRead($listview)) $sItem = StringTrimRight($sItem, 1) ; Will remove the pipe "|" from the end of the string MsgBox(0, "Selected Item", $sItem) EndFunc Func On_Close_Main() Exit EndFunc Link to comment Share on other sites More sharing options...
Solution MikahS Posted November 4, 2014 Solution Share Posted November 4, 2014 (edited) Have a look at Melba23's UDF >GUIListViewEx Taken from the description: Permits insertion, deletion, moving, dragging, sorting and editing of items within activated ListViews It is a great library, and I use it almost anytime I use ListViews Edited November 4, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2014 Moderators Share Posted November 4, 2014 (edited) Azevedo,Look at my GUIListViewEx UDF (the link is in my sig) which allows you to drag items within and between ListViews - as well as lot of other interesting things! M23Edit: Or in MikahS' post above! Edited November 4, 2014 by Melba23 MikahS 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...
Azevedo Posted November 4, 2014 Author Share Posted November 4, 2014 Thanks! Just what I need. What 'UDF' stands for anyway? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2014 Moderators Share Posted November 4, 2014 Azevedo,User Defined Function. 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...
Azevedo Posted November 4, 2014 Author Share Posted November 4, 2014 Nice work Melba23 MikahS 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2014 Moderators Share Posted November 4, 2014 Azevedo,Glad you like it. 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...
AndrewDaoust Posted March 14, 2016 Share Posted March 14, 2016 Here is an example that doesn't use somebody else's UDF. expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> #include <misc.au3> Opt("GUIOnEventMode", 1); GUICreate("", 200, 400) GUISetState(@SW_SHOW) $Listview = GUICtrlCreateListView("filename", 0, 0, 200, 400); _GUICtrlListView_SetExtendedListViewStyle($Listview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Arrange_List") _Create_List() While True Sleep(200) WEnd Func _Create_List() Local $Item While $Item <> "XXXXXXXX" $Item = $Item & "X" GUICtrlCreateListViewItem($Item, $Listview) Wend Endfunc Func _Arrange_List() $Selected = _GUICtrlListView_GetHotItem($Listview) If $Selected = -1 then Return While _IsPressed(1) WEnd $Dropped = _GUICtrlListView_GetHotItem($Listview) If $Dropped > -1 then _GUICtrlListView_BeginUpdate($Listview) If $Selected < $Dropped Then _GUICtrlListView_InsertItem($Listview, _GUICtrlListView_GetItemTextString($Listview, $Selected), $Dropped + 1) _GUICtrlListView_SetItemChecked($Listview, $Dropped + 1, _GUICtrlListView_GetItemChecked($Listview, $Selected)) _GUICtrlListView_DeleteItem($Listview, $Selected) ElseIf $Selected > $Dropped Then _GUICtrlListView_InsertItem($Listview, _GUICtrlListView_GetItemTextString($Listview, $Selected), $Dropped) _GUICtrlListView_SetItemChecked($Listview, $Dropped, _GUICtrlListView_GetItemChecked($Listview, $Selected + 1)) _GUICtrlListView_DeleteItem($Listview, $Selected + 1) EndIf _GUICtrlListView_EndUpdate($Listview) EndIf EndFunc Func _Close() Exit(0) EndFunc tarretarretarre and Ascer 2 Link to comment Share on other sites More sharing options...
unixman427 Posted April 14, 2017 Share Posted April 14, 2017 I have for the first time seen this library and tested the example code listed. It seems GuiListView.au3 is part of the mainstream production version. Can this be used with a list that is in a file or ini file or a registry record? Once I re-org the list, I am guessing it can be used to write that new list order to the source record, but I am looking to find some example code that does that. My goal is to create an Application that provides a list interface that allows adding an item to the list, OR down arrow to select from the list.. Possibly using this instead of a down select dialog(combobox) would be a better method. I do need to allow users to re-order items so it can be easier to find an item according to how each user thinks and operates. A possible alternative is to calculate usage weight for each time an item is selected, and move it up the list the more it is selected.. Using the check mark to select one is very useful as users will be selecting just one item at the time of use.. BUT, this method does not provide a way to manage the list, add items and delete items. I may be asking to much, but that is my goal. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 14, 2017 Moderators Share Posted April 14, 2017 (edited) unixman427, My GUIListViewEx UDF will certainly allow you to drag items within the ListView and also to read the new order, which can then be rewritten to the file used to load the ListView when next reloaded. if you can give me an idea of what you want to have as an initial load from file I will see what I can come up with as an example for you. M23 Edit: Welcome to the AutoIt forum, by the way. Edited April 14, 2017 by Melba23 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...
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