Sign in to follow this  
Followers 0
MariusN

_GUICtrlTreeView_Sort($treeview) "exclude"

7 posts in this topic

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

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 :evil:

#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 by MariusN

Share this post


Link to post
Share on other sites

No need to use _GUICtrlTreeView_Sort($treeview), better to sort the array before adding it.

#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

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

No need to use _GUICtrlTreeView_Sort($treeview), better to sort the array before adding it.

#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 ;)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks for your reply Kafu...bellieve it or not but i came up with a simple code

Nice idea :evil:, 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 by KaFu

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0