Sign in to follow this  
Followers 0
sayri80

Create treeview from a dynamic array

2 posts in this topic

Morning...

I am trying to create a program that will dynamically create a treeview list pulling from lines in a text file but i am having trouble with the array part i think.

Here is what i have so far, but it is not working.

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <TreeViewConstants.au3>

#include <StaticConstants.au3>

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <GuiEdit.au3>

#include <Date.au3>

#include <GuiButton.au3>

#include <File.au3>

#include <Array.au3>

;=======================================

;=======================================

;Vars

Global $storefile, $aArray[3]

;=======================================

;=======================================

;Gui

$Gui = GUICreate("THD Zoom",800,600,-1,-1,-1) ; build main gui

GUISetState(@SW_SHOW) ; set gui state to show

$treearea = GUICtrlCreateTreeView(1,5,200,580) ; build treelist area

;=======================================

;=======================================

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case Else

BuildList()

EndSwitch

WEnd

Func BuildList()

Dim $f = FileOpen(@ScriptDir & "\storelist.txt", 0) ; open file

Dim $CountLines = _FileCountLines(@ScriptDir & $f) ; count number of lines

Dim $CountLines = ($CountLines + 1) ; add 1 to the number of lines in the file

Dim $store; declare the array

;Dim $i = 1

For $i = 1 To $CountLines Step 1 ; for each line in the file, do the following:

$store[$i] = FileReadLine($f, $i) ; read each line in the file

If @error = -1 Then ExitLoop

$store[$i] = GUICtrlCreateTreeViewItem($store[$i],$treearea) ; create tree

GUICtrlCreateTreeViewItem("ISP", $store[$i]) ; add isp to tree

GUICtrlCreateTreeViewItem("PSP", $store[$i]) ; add psp to tree

GUICtrlCreateTreeViewItem("SWP", $store[$i]) ; add swp to tree

Next

FileClose($f)

EndFunc

Share this post


Link to post
Share on other sites



This example was very helpful for me.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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