Sign in to follow this  
Followers 0
Eli

add treeviewitems from an .ini

7 posts in this topic

#1 ·  Posted (edited)

I'm trying to dynamically update a treeview from an .ini

I got it so that it will create main headings from the ini sections

I cant seem to get it to populate with sub headings from the keys/values

can you have a piece of script create variables?

#include <Array.au3>
#include <GUIConstants.au3>
Dim $data
Dim $b

GUICreate("dynaTree test",300,300)

$tree = GUICtrlCreateTreeView(10, 10, 280, 280)
GUISetState(@SW_SHOW)

$section = IniReadSectionNames(@ScriptDir & "\phones.ini")


If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $section[0]
    GUICtrlCreateTreeViewItem($section[$i],$tree)
    Next
EndIf

While 1
   $msg = GUIGetMsg()

   Select
      Case $msg = $GUI_EVENT_CLOSE
         GUIDelete()
         Exit
         EndSelect
WEnd

this updates the tree with

-Head1

-Head2

-Head3

what I cant get is the sub items

-Head1

-item

-Head2

-item

my current script doesnt assign the treeviewitems to a variable for me to assign the items to

Edited by Eli

Share this post


Link to post
Share on other sites



ah, I do a search really I did! :P

I dont understand most of the code, but I should be able to piece it together!

thank you!

Share this post


Link to post
Share on other sites

whats the [#] after a variable?

ie $x[0]

Share this post


Link to post
Share on other sites

#include <Array.au3>
#include <GUIConstants.au3>
Dim $data
Dim $b
GUICreate("dynaTree test",300,300)

Dim $tree = GUICtrlCreateTreeView(10, 10, 280, 280)
GUISetState(@SW_SHOW)

$section = IniReadSectionNames(@ScriptDir & "\phones.ini")

If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
Dim $MainTreeViewItems[$section[0]+1]
$MainTreeViewItems[0] = $section[0]
    For $i = 1 To $section[0]
  $MainTreeViewItems[$i]  GUICtrlCreateTreeViewItem($section[$i],$tree)
    Next
EndIf

While 1
   $msg = GUIGetMsg()

   Select
      Case $msg = $GUI_EVENT_CLOSE
         GUIDelete()
         Exit
         EndSelect
WEnd 

   For $i = 1 To $section[0]
CreateItem($i*3, $i)
    Next

func CreateItem($ItemToAdd, $SectionNumber)
GUICtrlCreateTreeViewItem($ItemToAdd, $MainTreeViewItems[$SectionNumber])
endfunc

Does this help?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

whats the [#] after a variable?

ie $x[0]

while declareing the variable its the amount of stuff you can put in it

while using the variable it is a lot of strings and numbers ect that you can store or read

example:

Dim $Array[5] ;creates an array
for $i = 0 to 4 ;Fills the array
$array[$i] = "This is element " & $i
next
for $i = 0 to 4; displays the array
msgbox(0,"", $array[$i])
next
Edited by azeazezar

Share this post


Link to post
Share on other sites

awesome, good stuff

that script you posted azeazezar, only populated the sections in the treeview not the subheadings

I think I get whats going on, I'm going to play with it tomorrow morning when brain is fresh

thank you all!

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