Jump to content

Weird treeview issue


Go to solution Solved by Clark,

Recommended Posts

Hi there

I am getting a strange issue occuring with treeview.

The below code creates a three level treeview.  Each top level item has subitems, so all the top level items should have a "+" before them, allowing them to be expanded.

However, what is happening is that the last top level item is not showing a plus sign, until it is clicked once - then the plus sign appears.

Does anyone have an idea as to why this is happening?

Func _Populate_System_Treeview()
   local $iNumberSystems,$iCount,$iFields,$tempRecord,$tv1,$tv2,$tv3
   $sSQL="Select * from tbl_systems;"
   If Not _EzMYSql_Query($sSQL) Then
      MsgBox(0, "Query Error", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg())
   EndIf   
   $iNumberSystems = _EzMySql_Rows()                            ; Number of systems (rows) in the table
   global $tvi[$iNumberSystems][5]                              
   for $iCount = 0 to $iNumberSystems-1                         ; for each row in the table
      $tempRecord = _EzMySql_FetchData()                        ; Read the row into a temporary var
      for $iFields = 0 to 3
         $tvi[$iCount][$iFields]=$tempRecord[$iFields]              ; Fourth field reserved for pointer to treeviewbox items
      Next
   Next
   _ArraySort($tvi,0,0,0,0)
   for $iCount = 0 to $iNumberSystems-1
      Switch $tvi[$iCount][2]                           ; SYS_level field
         Case 1                                                 ; Top level
            $tv1=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $treeview)                 ; Display the item
            $tvi[$iCount][4]=$tv1
         Case 2                                                 ; Second level
            $tv2=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv1)
            $tvi[$iCount][4]=$tv2           
         Case 3                                                 ; THird level
            $tv3=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv2)
            $tvi[$iCount][4]=$tv3
         Case Else                                              ; Should never happen
            ; msgbox(0,"Warning","Undefined system level detected")
      EndSwitch
   Next
EndFunc
Link to post
Share on other sites
  • Moderators

Clark,

Unless you provide some runnable code which shows the problem, you are unlikely to get any useful responses. At present you are expecting us to write our own code to create a GUI to hold your treeview, create a SQL databasde to query with no idea what the resultant array format, and then add your function to even see the problem. Would you be prepared to do all that? :huh:

You post a runnable script which illustrates the problem and I will be happy to look into what might be happening. But at the moment there is absolutely no chance. ;)

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

 

Link to post
Share on other sites

OK, fair call, although I was hoping that someone could just spot the problem in the code without necessarily having to run it.

Anway, I have added some code around it to illustrate the issue - although now you don't need to click the last line of the treeview to make the final + appear - you just have to hover over it. 

#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>

$Form1_1 = GUICreate("Request for Change", 977, 917, 467, 37)

$TreeView = GUICtrlCreateTreeView(617, 190, 336, 300,BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)

_Populate_System_Treeview()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
         Case $GUI_EVENT_CLOSE
            Exit
  EndSwitch
WEnd



Func _Populate_System_Treeview()
   ; Due to the retardness of the mySQL udf this has to be build as an in-memory array rather than straight to screen
   local $iNumberSystems=27,$iCount,$iFields,$tempRecord[5],$tv1,$tv2,$tv3
   global $tvi[$iNumberSystems][5]
   for $iCount = 0 to $iNumberSystems-1                         ; for each row in the table
      $tempRecord = _Emulate_EzMySql_FetchData($iCount)         ; Read the row into a temporary var
      for $iFields = 0 to 3
         $tvi[$iCount][$iFields]=$tempRecord[$iFields]          ; Fourth field reserved for pointer to treeviewbox items
      Next
   Next
   _ArraySort($tvi,0,0,0,0)
   for $iCount = 0 to $iNumberSystems-1
      Switch $tvi[$iCount][2]                                   ; SYS_level field
         Case 1                                                 ; Top level
            $tv1=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $treeview) ; Display the item
            $tvi[$iCount][4]=$tv1
         Case 2                                                 ; Second level
            $tv2=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv1)
            $tvi[$iCount][4]=$tv2           
         Case 3                                                 ; THird level
            $tv3=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv2)
            $tvi[$iCount][4]=$tv3
         Case Else                                                  ; Should never happen
            ; msgbox(0,"Warning","Undefined system level detected")
      EndSwitch
   Next
EndFunc

Func _Emulate_EzMySql_FetchData($idx)
   local $retstring[5],$lCntr
   local $tvi[28][3] = [ _
   [100,"SAP ERP",                  1], _
   [110,"(CRM) Customer Relationship Management",   1], _
   [111,"Interaction Centre",                   2], _
   [112,"Activity and CRM Ticket Mgmt",             3], _
   [113,"Grants CRM Mgmt",                      3], _
   [114,"Electronic Document Records Mgmt System",3], _ 
   [120,"(ECC) ERP Central Component",          3], _
   [121,"Finance Controlling and Funds Mgmt",       2], _ 
   [122,"Human Capital Mgmt",                       3], _ 
   [123,"Materials Mgmt",                           3], _  
   [124,"Treasury Mgmt System",                 3], _   
   [130,"Enterprise Portal",                    3], _
   [140,"Business Intelligence/Warehouse",  2], _
   [150,"XI / PI Interfaces",                   2], _
   [160,"Solution Manager",                 2], _   
   [200,"GOS",                      2], _
   [210,"Lotos",                            1], _
   [220,"BOS",                              2], _
   [230,"Terminal",                             2], _   
   [300,"Corporate IT",             2], _
   [310,"Email",                            1], _
   [320,"Intranet",                         2], _
   [400,"Digital Point of Presence",    2], _
   [410,"Play Online",                          1], _
   [420,"Retail Link",                          2], _ 
   [430,"Corporate Website General",            2], _
   [440,"Corporate Website Grants",             2]]
   for $lCntr = 0 to 2
         $retstring[$lCntr]=$tvi[$idx][$lCntr]
   Next
   return ($retstring)
endfunc
Link to post
Share on other sites

Good call NewPlaza, that seems to have fixed it on my system at least.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

Thanks for that good try.

I tried that previously, but unfortunately it doesn't fix it on my system.  Not on the "real" program nor the "test" program I have included.

In fact, on the test program it makes it emulate the real program, in that the + does not appear until I click the last line.  Very strange.

Link to post
Share on other sites

I tried your example script and I was seeing the problem before moving the GUISetState function below the line that creates the treeview. After moving it, the problem went away, at least on the 2 different computers I ran it on.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

One trick you could use is adding this line after your return from creating all of the treeview items.

GUICtrlDelete(GUICtrlCreateTreeViewItem("",$TreeView))

This adds an additional root level treeview item and immediately deletes it, which makes the bottom treeview item have the "+" sign show up every time.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

It works here (Windows XP), so it may be a missing control redraw call (in Windows 7?)

This should fix the issue (although I can't test it to adapt the redraw message).

_WinAPI_RedrawWindow($Form1_1, 0, $hTreeeView, $RDW_ERASENOW)
Br, FireFox. Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Link to post
Share on other sites
  • 3 weeks later...

@all - Follow-up

I recently had exactly the same problem.  Adding a "_guictrltreeview_beginupdate",  "_guictrltreeview_endupdate" pair fixed it...

#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GuiTreeView.au3> ; <---- added for _guictrltreeview* functions

$Form1_1 = GUICreate("Request for Change", 977, 917, 467, 37)

$TreeView = GUICtrlCreateTreeView(617, 190, 336, 300,BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)

_Populate_System_Treeview()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
         Case $GUI_EVENT_CLOSE
            Exit
  EndSwitch
WEnd



Func _Populate_System_Treeview()
    ;
    _GUICtrlTreeView_BeginUpdate($treeview) ; <-----  added
    ;
   ; Due to the retardness of the mySQL udf this has to be build as an in-memory array rather than straight to screen
   local $iNumberSystems=27,$iCount,$iFields,$tempRecord[5],$tv1,$tv2,$tv3
   global $tvi[$iNumberSystems][5]
   for $iCount = 0 to $iNumberSystems-1                         ; for each row in the table
      $tempRecord = _Emulate_EzMySql_FetchData($iCount)         ; Read the row into a temporary var
      for $iFields = 0 to 3
         $tvi[$iCount][$iFields]=$tempRecord[$iFields]          ; Fourth field reserved for pointer to treeviewbox items
      Next
   Next
   _ArraySort($tvi,0,0,0,0)
   for $iCount = 0 to $iNumberSystems-1
      Switch $tvi[$iCount][2]                                   ; SYS_level field
         Case 1                                                 ; Top level
            $tv1=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $treeview) ; Display the item
            $tvi[$iCount][4]=$tv1
         Case 2                                                 ; Second level
            $tv2=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv1)
            $tvi[$iCount][4]=$tv2
         Case 3                                                 ; THird level
            $tv3=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv2)
            $tvi[$iCount][4]=$tv3
         Case Else                                                  ; Should never happen
            ; msgbox(0,"Warning","Undefined system level detected")
      EndSwitch
  Next
    ;
    _GUICtrlTreeView_endUpdate($treeview) ; <--- added
    ;

EndFunc

Func _Emulate_EzMySql_FetchData($idx)
   local $retstring[5],$lCntr
   local $tvi[28][3] = [ _
   [100,"SAP ERP",                  1], _
   [110,"(CRM) Customer Relationship Management",   1], _
   [111,"Interaction Centre",                   2], _
   [112,"Activity and CRM Ticket Mgmt",             3], _
   [113,"Grants CRM Mgmt",                      3], _
   [114,"Electronic Document Records Mgmt System",3], _
   [120,"(ECC) ERP Central Component",          3], _
   [121,"Finance Controlling and Funds Mgmt",       2], _
   [122,"Human Capital Mgmt",                       3], _
   [123,"Materials Mgmt",                           3], _
   [124,"Treasury Mgmt System",                 3], _
   [130,"Enterprise Portal",                    3], _
   [140,"Business Intelligence/Warehouse",  2], _
   [150,"XI / PI Interfaces",                   2], _
   [160,"Solution Manager",                 2], _
   [200,"GOS",                      2], _
   [210,"Lotos",                            1], _
   [220,"BOS",                              2], _
   [230,"Terminal",                             2], _
   [300,"Corporate IT",             2], _
   [310,"Email",                            1], _
   [320,"Intranet",                         2], _
   [400,"Digital Point of Presence",    2], _
   [410,"Play Online",                          1], _
   [420,"Retail Link",                          2], _
   [430,"Corporate Website General",            2], _
   [440,"Corporate Website Grants",             2]]
   for $lCntr = 0 to 2
         $retstring[$lCntr]=$tvi[$idx][$lCntr]
   Next
   return ($retstring)
endfunc

kylomas

edit: @Clark - Your array to populate the treeview requires strict order of items in the array.  See thread

for another way to do this using an array.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to post
Share on other sites

Maybe because the EndUpdate function redraws the treeview.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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

    No registered users viewing this page.

  • Similar Content

    • By Vipan
      Hi,
      I have developed Java maven based framework and integrated AutoIt in it. I am automated a desktop application. During automation, I am facing below issue. Can someone please guide me?
      1. I am unable to select a menu option from a nested tree view:
      Example-
      TreeTitle1
         TreeTitle1.1
              TreeOption ToSelect
      In above case, TreeTitle1 is a folder in which TreeTitle2 is another folder and the TreeOptionToSelect is the one i want to select.
      I tried below command:
      AutoItX autoIt = new AutoItX();
      autoIt.controlTreeViewExpand(pagetitle,"",treecontrolname,"#0|#0");
      autoIt.controlTreeViewSelect(pagetitle,"",treecontrolname,"#0|#0|#0");
       
      But it didn't work... kindly help
    • By jcpetu
      Hi people, I'm trying to dynamically populate a TreeView based on a script from Water that I modified for my needs. but I can't figured it out how to make it work.
      Here what I have in case anyone can help me, thanks in advance:
      #include <array.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> Local $aTV1[14][3] = [ _ ['1', 'Text 1', -1], _ ;-1 idicates it's an index item ['2', 'Text 2',-1], _ ['3', 'Text 3',-1], _ ['1-1', 'Text 1-1',0], _ ['1-2', 'Text 1-2',0], _ ['2-1', 'Text 2-1',0], _ ['2-2', 'Text 2-2',0], _ ['2-1-1', 'Text 2-1-1',0], _ ['2-1-2', 'Text 2-1-2',0], _ ['2-1-2-1', 'Text 2-1-2-1',0], _ ['2-1-2-1-1', 'Text 2-1-2-1-1',0], _ ['3-1', 'Text 3-1',0], _ ['3-1-1', 'Text 3-1-1',0], _ ['3-1-1-1', 'Text 3-1-1-1',0]] ;_ArrayDisplay($aTV1) Local $Gui = GUICreate('TreeView Example', 500, 600) Local $tv = GUICtrlCreateTreeView(10, 30, 450, 550) GUISetState() _pop_treeview($tv, $aTV1) While 1 Switch GUIGetMsg() Case $gui_event_close Exit EndSwitch WEnd Func _pop_treeview($hTV, $array) Local $TimeInitial = TimerInit(), $Hours, $Mins, $Secs, $item _ArraySort($array, 0, 0, 0, 0) ;------------------------- sort Ascending on column 0 ;_ArrayDisplay($array) $idxroot = _GUICtrlTreeView_Add($hTV, 0, "index") For $i = 0 To UBound($array) - 1 ConsoleWrite("$array[" & $i & "][" & 0 & "] = " & $array[$i][0] & @CRLF) If $array[$i][0] = '' Then ExitLoop ;--------------- Exit at first empty element $item = '' If $array[$i][2] = -1 Then ;------------------------ Add root element _GUICtrlTreeView_AddChild($hTV, $idxroot, $array[$i][1]) Else $item = StringLeft($array[$i][0], StringInStr($array[$i][0], "-", 1, -1) - 1) ConsoleWrite("$item = " & $item & @CRLF) $Found = _ArrayBinarySearch($array, $item, 0, 0, 0) ;search on column 0 Switch $Found Case 0 ;----------------------------------- Value wasn't found in array ConsoleWrite("Item NOT found @error= " & @error & @CRLF) Case Else ConsoleWrite("Item found " & @CRLF) _GUICtrlTreeView_AddChild($hTV, $Found, $array[$i][1]) EndSwitch EndIf Next _GUICtrlTreeView_Expand($hTV) EndFunc ;==>_pop_treeview  
    • By MesterPerfect
      good morning
      this is the first post here in the autoit forums
      i hope that you can help me in my problem
      i have a JSON encoded
      it a map of my forums
      where i want to make a treeview that have the same type of map
      e.g
      a system (as category)
      windows (as sub category)
      software (as an child item in the windows category)
      .....
      i don't know how to do that
      so, i know that i can do that using the json functions
      but i need your help about how we can do it as the type that i told you
      by the way i need to put the sub info for each item in an array that give me the ability to manage my items
      e.g
      can post thread
      can reply
      message cound ...
      you just give me a small example and i can continue.
      am sorry if this against the rules of the forum.
      but i realy searched a lot but i couldn't
      i hope some one give me the way.
      thank you very much in advance
       
      here is the link of json forum
      https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/
      and here is my encoded json file
       
      { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }  
    • By Burgs
      Hello,
        I am having great difficulty with something I would have thought to be fairly easy.  I have an array containing (military) organization strings, similar to this:
      42nd Battalion
       Company A
        1st Platoon
         1st Squad
         2nd Squad
         3rd Squad
        2nd Platoon
         ...1st, 2nd, 3rd Squad
        3rd Platoon
        ...1st, 2nd, 3rd Squad
       Company B
        ...etc...
      I also have an associated array that contains the 'hierarchy' information associated with each string..."0", "1","2", etc   ...therefore using example above the "0" would associate with "42nd Battalion", while "1" would be "Company A", "2" is "1st Platoon", etc.  Each sequential number is a 'child' of the preceding number.  Therefore the information above would appear in the array as "0", "1", "2", "3", "3", "3", "2", "3", "3", "3", "2", "3", "3", "3", "1", etc...
        My issue is that I'm having great difficulty creating a 'Treeview' control using this information.  Mainly due to the fact that entries can, and will...repeat (for example multiple entries for "Company A", "Company B", "1st Platoon", "1st Squad", etc, etc).  The following code is operative, however it does not create the treeview items as 'child' entries of one another...it simply lists each item as a separate entity.
      For $_populate = 0 to Ubound($_HIERARCHY) - 1 _GUICtrlTreeView_BeginUpdate($idTreeView) _GUICtrlTreeView_Add($idTreeView, $_HIERARCHY[$_populate], String($_STRUCTURES[$_populate])) _GUICtrlTreeView_EndUpdate($idTreeView) Next ;Next $_populate, cycle thru '$_HIERARCHY' array to build 'TREEVIEW' Controls As I mentioned earlier I thought I could manage this...however i'm pulling out quite a bit of my hair trying to get this working properly...any help would be appreciated.  I thank you in advance. 
       
    • By xtcislove
      Hello,
      i stuck again,
      Im using this function to create a treeview from root dir.
       
      ;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> Global $sPath = @ScriptDir Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() _CreatePath($sPath, $idTreeView) Do Until GUIGetMsg() = -3 Func _CreatePath($sPath, $idParent) Local $aFolder, $aFiles, $idItem If StringRight($sPath, 1) <> '\' Then $sPath &= '\' $aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS) If Not @error Then For $i = 1 To $aFolder[0] $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) Next EndFunc Folder Structure:

      Folder1
      Folder2
      Folder3
      If a file exists in multiple folders, i like to color it red, if not green. 

      I know how to do this for files, but nut for the folders.

      Because if there is only 1 file in Folder2 that is also in Folder1 that it should only color this single file red, inlcuding its whole tree.

      The Folder1 and Folder2 should be red in this case, too. Other files and trees should stay green.
       
      Edit:
      Basically i like to color a file and its belonging tree red if the file exists more than 1 time.
×
×
  • Create New...