pocs-105835 Posted March 25, 2020 Share Posted March 25, 2020 Hi When I have a listview on a tab and use _GUICtrlListView_DeleteAllItems then it simply deletes the tab. Why does that happen and is there perhaps a workaround? What I'm trying to do is reload the listview from a previous saved configuration file. Here is an example script. (press the button to execute _GUICtrlListView_DeleteAllItems) expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <File.au3> Example() Func Example() GUICreate("My GUI Tab", 350, 600); will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) Local $idTab = GUICtrlCreateTab(10, 10, 330, 600) GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) $button = GUICtrlCreateButton("_GUICtrlListView_DeleteAllItems", 20, 50, 250, 50) $idRunbookList = GUICtrlCreateListView("Runbook Selection",35,300,300,200) Global $aFileListArray = _FileListToArray(@MyDocumentsDir) _GUICtrlListView_SetColumnWidth($idRunbookList, 0, 270) For $i = 1 to UBound($aFileListArray) -1 _GUICtrlListView_AddItem($idRunbookList, $aFileListArray[$i] ,-1, $i) Next GUICtrlCreateTabItem("tab----1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo|guinness", "Jon"); default Jon GUICtrlCreateButton("OK1", 80, 50, 50, 20) GUICtrlCreateTabItem("tab2") GUICtrlCreateLabel("label2", 30, 80, 50, 20) GUICtrlCreateButton("OK2", 140, 50, 50) GUICtrlCreateTabItem(""); end tabitem definition GUICtrlCreateLabel("Click on tab and see the title", 20, 130, 250, 20) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop If $idMsg = $button Then _GUICtrlListView_DeleteAllItems($idRunbookList) EndIf If $idMsg = $idTab Then ; display the clicked tab WinSetTitle("My GUI Tab", "", "My GUI Tab" & GUICtrlRead($idTab)) EndIf WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 25, 2020 Moderators Share Posted March 25, 2020 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team 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...
pocs-105835 Posted March 25, 2020 Author Share Posted March 25, 2020 My excuse is that I didn't read with attention Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 25, 2020 Moderators Share Posted March 25, 2020 pocs-105835, You are setting the parameter value of the _GUICtrlListView_AddItem function which, as the help file explains, can duplicate the ControlIds of other GUI controls: Quote As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended. So change that parameter to "$i + 1000" as suggested in the Help file and all will be well. 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...
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