MariusN Posted January 6, 2010 Share Posted January 6, 2010 i have a treeview with 6 items...Sometimes my tree will only have 3 items...When i use the "_GUICtrlTreeView_Sort($treeview)" function, it adds the "empty" lines as well in the beginning...How can i make this to only sort the strings, but discard the empty spaces? Basicly after this action i only want to see the 3 items, and not the empty spaces as well...thx mates Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2010 Moderators Share Posted January 6, 2010 MariusN, There must be a way of limiting the items in your Tree at creation. Post your code and we can see what might be done. 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...
MariusN Posted January 6, 2010 Author Share Posted January 6, 2010 (edited) MariusN, There must be a way of limiting the items in your Tree at creation. Post your code and we can see what might be done. M23 Not the best of codes, but here goes. I basicly want, lets say a guy puts something in the 3rd row, it must show as the first file in the tree, and not the 3rd file in the tree expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <Process.au3> Local $button1, $msg, $file[10], $hListView1, $hListView2, $1, $2, $3, $4, $5, $6, $hListItem, $hListItem2 Local $treeview, $read[20], $fDblClk, $sText, $item[10], $clear[6], $font, $copy1, $i, $button2, $test, $zip $font = "Times New Roman" GUICreate(" Your Own Utilities", 450, 440, -1, -1, -1, $WS_EX_ACCEPTFILES); WS_EX_ACCEPTFILES GUICtrlCreateLabel("Please use Drag 'n Drop", 150, 10, 180, 20) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 12, 700, 2, $font) GUICtrlCreateLabel("Store Utilities for Archiving Here...", 110, 220, 250, 20) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 12, 700, 2, $font) $file[0] = GUICtrlCreateInput("", 80, 40, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[1] = GUICtrlCreateInput("", 80, 70, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[2] = GUICtrlCreateInput("", 80, 100, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[3] = GUICtrlCreateInput("", 80, 130, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[4] = GUICtrlCreateInput("", 80, 160, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[5] = GUICtrlCreateInput("", 80, 190, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $treeview = GUICtrlCreateTreeView(30, 250, 390, 150, BitOR($TVS_LINESATROOT, $TVS_FULLROWSELECT, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $item[0] = GUICtrlCreateTreeViewItem($read[0], $treeview) $item[1] = GUICtrlCreateTreeViewItem($read[1], $treeview) $item[2] = GUICtrlCreateTreeViewItem($read[2], $treeview) $item[3] = GUICtrlCreateTreeViewItem($read[3], $treeview) $item[4] = GUICtrlCreateTreeViewItem($read[4], $treeview) $item[5] = GUICtrlCreateTreeViewItem($read[5], $treeview) $button1 = GUICtrlCreateButton(" Add Files to STORE! ", 40, 410, -1, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 $read[0] = GUICtrlRead($file[0]) $read[1] = GUICtrlRead($file[1]) $read[2] = GUICtrlRead($file[2]) $read[3] = GUICtrlRead($file[3]) $read[4] = GUICtrlRead($file[4]) $read[5] = GUICtrlRead($file[5]) GUICtrlSetData($item[0], $read[0]) ;treeview GUICtrlSetData($item[1], $read[1]) GUICtrlSetData($item[2], $read[2]) GUICtrlSetData($item[3], $read[3]) GUICtrlSetData($item[4], $read[4]) GUICtrlSetData($item[5], $read[5]) _GUICtrlTreeView_Sort($treeview) EndSelect WEnd Edited January 6, 2010 by MariusN Link to comment Share on other sites More sharing options...
KaFu Posted January 6, 2010 Share Posted January 6, 2010 No need to use _GUICtrlTreeView_Sort($treeview), better to sort the array before adding it. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <Process.au3> Local $button1, $msg, $file[6], $hListView1, $hListView2, $1, $2, $3, $4, $5, $6, $hListItem, $hListItem2 Local $treeview, $read[6], $fDblClk, $sText, $item[6], $clear[6], $font, $copy1, $i, $button2, $test, $zip $font = "Times New Roman" GUICreate(" Your Own Utilities", 450, 440, -1, -1, -1, $WS_EX_ACCEPTFILES); WS_EX_ACCEPTFILES GUICtrlCreateLabel("Please use Drag 'n Drop", 150, 10, 180, 20) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 12, 700, 2, $font) GUICtrlCreateLabel("Store Utilities for Archiving Here...", 110, 220, 250, 20) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 12, 700, 2, $font) $file[0] = GUICtrlCreateInput("", 80, 40, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[1] = GUICtrlCreateInput("", 80, 70, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[2] = GUICtrlCreateInput("", 80, 100, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[3] = GUICtrlCreateInput("", 80, 130, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[4] = GUICtrlCreateInput("", 80, 160, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[5] = GUICtrlCreateInput("", 80, 190, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $treeview = GUICtrlCreateTreeView(30, 250, 390, 150, BitOR($TVS_LINESATROOT, $TVS_FULLROWSELECT, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $button1 = GUICtrlCreateButton(" Add Files to STORE! ", 40, 410, -1, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 _GUICtrlTreeView_DeleteAll($treeview) $TV_count = 0 ReDim $read[6] ReDim $item[6] for $i = 0 to 5 if StringLen(GUICtrlRead($file[$i])) > 0 then $TV_count +=1 $read[$i] = GUICtrlRead($file[$i]) endif Next if $TV_count > 0 then _ArraySort($read,1) ReDim $read[$TV_count] ReDim $item[$TV_count] _ArraySort($read) for $i = 0 to UBound($read) - 1 $item[$i] = GUICtrlCreateTreeViewItem($read[$i],$treeview) Next endif EndSelect WEnd OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2010 Moderators Share Posted January 6, 2010 MariusN, What KaFu said! 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...
MariusN Posted January 6, 2010 Author Share Posted January 6, 2010 No need to use _GUICtrlTreeView_Sort($treeview), better to sort the array before adding it. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <Process.au3> Local $button1, $msg, $file[6], $hListView1, $hListView2, $1, $2, $3, $4, $5, $6, $hListItem, $hListItem2 Local $treeview, $read[6], $fDblClk, $sText, $item[6], $clear[6], $font, $copy1, $i, $button2, $test, $zip $font = "Times New Roman" GUICreate(" Your Own Utilities", 450, 440, -1, -1, -1, $WS_EX_ACCEPTFILES); WS_EX_ACCEPTFILES GUICtrlCreateLabel("Please use Drag 'n Drop", 150, 10, 180, 20) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 12, 700, 2, $font) GUICtrlCreateLabel("Store Utilities for Archiving Here...", 110, 220, 250, 20) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 12, 700, 2, $font) $file[0] = GUICtrlCreateInput("", 80, 40, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[1] = GUICtrlCreateInput("", 80, 70, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[2] = GUICtrlCreateInput("", 80, 100, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[3] = GUICtrlCreateInput("", 80, 130, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[4] = GUICtrlCreateInput("", 80, 160, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $file[5] = GUICtrlCreateInput("", 80, 190, 350, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $treeview = GUICtrlCreateTreeView(30, 250, 390, 150, BitOR($TVS_LINESATROOT, $TVS_FULLROWSELECT, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $button1 = GUICtrlCreateButton(" Add Files to STORE! ", 40, 410, -1, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 _GUICtrlTreeView_DeleteAll($treeview) $TV_count = 0 ReDim $read[6] ReDim $item[6] for $i = 0 to 5 if StringLen(GUICtrlRead($file[$i])) > 0 then $TV_count +=1 $read[$i] = GUICtrlRead($file[$i]) endif Next if $TV_count > 0 then _ArraySort($read,1) ReDim $read[$TV_count] ReDim $item[$TV_count] _ArraySort($read) for $i = 0 to UBound($read) - 1 $item[$i] = GUICtrlCreateTreeViewItem($read[$i],$treeview) Next endif EndSelect WEnd Thanks for your reply Kafu...bellieve it or not but i came up with a simple code Case $msg = $button1 $read[0] = GUICtrlRead($file[0]) $read[1] = GUICtrlRead($file[1]) $read[2] = GUICtrlRead($file[2]) $read[3] = GUICtrlRead($file[3]) $read[4] = GUICtrlRead($file[4]) $read[5] = GUICtrlRead($file[5]) $read[6] = GUICtrlRead($file[6]) $j = 0 $i = 0 Do If $read[$i] <> "" Then $var = GUICtrlSetData($item[$j], $read[$i]) $i = $i + 1 $j = $j + 1 Else $i = $i + 1 EndIf Until $i = 6 Thanks to all the other guys as well for trying to help Link to comment Share on other sites More sharing options...
KaFu Posted January 6, 2010 Share Posted January 6, 2010 (edited) Thanks for your reply Kafu...bellieve it or not but i came up with a simple codeNice idea , I too utilize this technique from time to time, but in this case it does not sort the entries and leaves empty treeview items at the end ... better create the items in runtime. Edited January 6, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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