Jump to content

Recommended Posts

  • Moderators
Posted

maniootek,

You can very easily write a small function to convert an array to a suitably formatted string which the UDF will accept:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <String.au3>

#include "GUITreeViewEx.au3"

Global $aTV_List_1[9][3] = [ _
                        ["Food", "Fruit", "Apple"], _
                        ["Food", "Meat", "Steak"], _
                        ["Food", "Meat", "Chicken"], _
                        ["Food", "Dairy", "Cheese"], _
                        ["Drinks", "Water"], _
                        ["Drinks", "Fizzy", "Cola"], _
                        ["Drinks", "Juice", "Orange"], _
                        ["Drinks", "Hot Drinks", "Tea"], _
                        ["Drinks", "Hot Drinks", "Coffee"]]

$sTV_Data_1 = _ConvertArray($aTV_List_1)

Global $aTV_List_2[8][3] = [ _
                        ["A", "AA", "AAA"], _
                        ["A", "AA", "AAB"], _
                        ["B", "BA"], _
                        ["B", "BB", "BBA"], _
                        ["B", "BB", "BBB"], _
                        ["B", "BB", "BBC"], _
                        ["C", "CA"], _
                        ["D", "DA", "DAA"]]

$sTV_Data_2 = _ConvertArray($aTV_List_2)

; Create GUI
Global $hGUI = GUICreate("Test", 500, 500)

; Create TreeView
Global $cTV_1 = GUICtrlCreateTreeView(10, 10, 230, 350, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES))

_GUITreeViewEx_LoadTV($cTV_1, $sTV_Data_1)

; Expand TreeView
_GUICtrlTreeView_Expand($cTV_1)

Global $cTV_2 = GUICtrlCreateTreeView(260, 10, 230, 350, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES))

_GUITreeViewEx_LoadTV($cTV_2, $sTV_Data_2)

; Expand TreeView
_GUICtrlTreeView_Expand($cTV_2)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _ConvertArray($aTV_List)
    $sString = ""
    $iColCount = UBound($aTV_List, 2)
    Local $aCurrLevel[$iColCount]
    For $i = 0 To UBound($aTV_List) - 1
        For $j = 0 To $iColCount - 1
            If $aTV_List[$i][$j] <> "" And $aTV_List[$i][$j] <> $aCurrLevel[$j] Then
                $aCurrLevel[$j] = $aTV_List[$i][$j]
                $sString &= _StringRepeat("~", $j) & $aTV_List[$i][$j] & "|"
            EndIf
        Next
    Next
    Return StringTrimRight($sString, 1)
EndFunc

But I am not adding that wrapper function to the UDF or I will have to write a conversion function for every imaginable data format. If the user does not like my chosen format for the TreeView loading string then it is up to them to write a wrapper to convert their desired format into the one used by the UDF.

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted (edited)

Thank you for your answer. I think this could be most universal function for populating tree view from array.

Anyway, I have started to use your UDF and sometimes when I click on any place on tree view area i got this error:

57074673492ad_GuiTreeViewExerror.PNG.d50

is it common problem?

I have created sample of my code when this error show up:

#include <Array.au3>
#include "GUITreeViewEx.au3"

$gui = GUICreate("Form1", 343, 520);, 1565, 583)

$button = GUICtrlCreateButton("Populate", 248, 8, 81, 41)
$TreeView1 = GUICtrlCreateTreeView(10, 96, 250, 300, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_CHECKBOXES))
GUISetState(@SW_SHOW)


_GUITreeViewEx_RegMsg()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3 ;$GUI_EVENT_CLOSE
            Exit
        Case $button
            $fill = "Food|~Fruit|~~Apple|~Meat|~~Steak|~~#Chicken|~Dairy|~~Cheese|Drinks|~Water|~Fizzy|~~#Cola|~Juice|~~Orange|~Hot Drinks|~~Tea|~~Coffee"
            PopulateTreeView($fill)
    EndSwitch
    _GUITreeViewEx_AutoCheck()
WEnd

Func PopulateTreeView($sTreeViewFill)
    _GUICtrlTreeView_DeleteAll($TreeView1)
    _GUITreeViewEx_LoadTV($TreeView1, $sTreeViewFill)
    _GUICtrlTreeView_Expand($TreeView1)
    _GUITreeViewEx_InitTV($TreeView1)
EndFunc

I have tried to create script based on your example "GUITreeViewEx_Example_Loop.au3"

any idea what's wrong?

Edit:

I have noticed that problem occur when i press the buttons more than 1 time (pupulatetreeview)

Edited by maniootek
Posted

I think I found the problem. I just simple forgot to use _GUITreeViewEx_CloseTV function after use _GUICtrlTreeView_DeleteAll and before I use  _GUITreeViewEx_LoadTV with new data.

  • Moderators
Posted

maniootek,

Yes, that is the solution.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

  • Moderators
Posted

maniootek,

I have been trying to reproduce the problem without any success. Unless you can provide me with a reproducible series of actions to get the error I am afraid I cannot really do any debugging.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

  • 1 year later...
  • 11 months later...
  • Moderators
Posted

joiner,

Delighted you find the UDF useful.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

  • Moderators
Posted

MattHiggs,

Your posts concerning ListViews have been split off and can been found here.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

  • 5 years later...
Posted (edited)

Hi Melba,

sorry to jump so late into this topic.

I want to check parent and all children are checked.

If i uncheck a child then, i want the parents to be unchecked.

This i cannot get working.

Thanks for assistance.

Cheers mike

Edited by mike1950r
  • Moderators
Posted

mike1950r,

And what has this code to do with my UDF? You do not use it at all!

Are you asking if the UDF can help you do as you require? If so, then please provide me with a runnable script showing an example of the treeview you wish to manipulate, including data to fill it.

But I must warn you that I do not believe that the UDF can do what you wish. You imply that unchecking a single child will uncheck the parent - normal practice is to keep the parent ticked unless all the children are unchecked.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

Hello Melba23, really great UDF. Looks great and works fantastic. However, I would like to select the parent elements with the space key. But then the child elements are no longer automatically selected. Is there a solution for this? Unfortunately I don't know where to start. Thank you in advance.

  • Moderators
Posted (edited)

Felicitas,

Glad you like it. Try this Beta version: GUITreeViewEx_Test.au3

Good to go?

M23

Edited by Melba23
Modified code

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

 

Hello Melba, sorry for answering so late. Thank you very much, that works wonderfully. From your comment I was also able to see where you did something to the code. This helps me understand it a little better. Thanks

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...