Jump to content

add treeviewitems from an .ini


Eli
 Share

Recommended Posts

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
Link to comment
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?

Link to comment
Share on other sites

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
Link to comment
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!

Link to comment
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
 Share

  • Recently Browsing   0 members

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