Jump to content
Sign in to follow this  
cueclub

Question about Tree View

Recommended Posts

cueclub

I am trying to pull information from different files.

They will all be grouped together by name.

In treeview I would have

Last Name << This labels would be the actual name.

-First Name

-Address

-Phone Number

I currently have the above information saved into 4 different ini files.

I am writting the values as Section Keys.

Like so:

IniWriteSection(@ScriptDir & "\First Name.ini", GUICtrlRead($Name),"")

Then read it into an array such as

Local $Name2 = IniReadSectionNames(@ScriptDir & "\First Name.ini")

For $I = 1 To $Name2[0]
        GUICtrlSetData(-1, $Name2[$I] & "|")
    Next

The problem is I can not get the separate values into the TreeView based on what last name is selected.

Here is what I have so far:

Onlastnamesearch("CueClub")
Func Onlastnamesearch($LastName)
    
    

    GUICreate("Notes for " & $LastName, 300, 250, -1, -1, "", $WS_EX_TOPMOST)
GUICtrlCreateLabel("LAST NAME", 5, 10, 60, 40)

Local $Tmp = IniReadSectionNames(@ScriptDir & "\Last Name.ini")

Local $Tmp2 = GUICtrlCreateTreeView(5, 50, 170, 100)
For $I = 1 To $tmp[0]

        $tmp3 = GUICtrlCreateTreeViewItem($tmp[$i], $Tmp2)
        $FirstName = GUICtrlCreateTreeViewItem("First Name", $Tmp3)
        $Address = GUICtrlCreateTreeViewItem("Address", $Tmp3)
        $PhoneNumber = GUICtrlCreateTreeViewItem("Phone Number", $Tmp3)
    Next

    Local $exit = GUICtrlCreateButton("Exit", 5, 160, 50, 20)
    GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $exit Or $msg = $GUI_EVENT_CLOSE
                ExitLoop


                


            
                


        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example

As you can see above, I can get the treeview to populate, and even the tree items, However I am stumped as to how to pull the data from the separate ini files and display them based on what is clicked on the treeview.

I have read the help file, and searched here a bit, but it is a bit confusing for me.

Any help would be appreciated.

CC

Share this post


Link to post
Share on other sites
Melba23

cueclub,

Please post some examples of the ini files - without them we are just guessing how to extract the data. :)

If you attach them, you will need to change their extension as the forum software does not accept .ini files. Or you can put the content of each file between [code]...[/code] tags. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
cueclub

I seem to have forgotten that part of it Sorry bout that.

The 1st ini is lastname.ini

[lastname1]
[lastname2]
[lastname3]
[lastname4]
[lastname5]
[lastname6]
[lastname7]
[lastname8]
[lastname9]
[lastname10]

The 2nd ini is phonenums.ini

[555-555-5555]
[222-222-2222]
and so on.....

What I need to do is get the Phne number when I click on the last name in the treeview area.

Hope this explains it a bit more.

CC

Share this post


Link to post
Share on other sites
BrewManNH

Put them all into one ini file, with the sections being the last name, or last name and first name and the values/keys being the rest of the information. Having them in separate ini files makes it impractical to coordinate a name with a phone number for example.


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

Share this post


Link to post
Share on other sites
cueclub

Well I suppose I could do that, However when it gets to a company name for example. What would be the best way to write the different phone numbers to the name "Section" ?

Array perhaps?

Share this post


Link to post
Share on other sites
BrewManNH

If you put them as phone#1 through phone#xx in the section for the company name, you could use IniReadSection to get all of the keys that are in that section.


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

Share this post


Link to post
Share on other sites
cueclub

Ok will give that a try. thx

CC

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  

  • Similar Content

    • xtcislove
      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.
    • xtcislove
      By xtcislove
      Hello,

      im searching like 6 hours and i didnt found the right solution.

      Im trying to build a treeview from a directory and its subfolders etc.

      This function give me right treeview, but i cant color each item seperated.

       
      #include <GuiTreeView.au3> $hGui = GUICreate("Demo1", 600, 400) $hTreeView = _GUICtrlTreeView_Create($hGui, 10, 10, 580, 380) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) ListFiles_ToTreeView(@ScriptDir, 0) _GUICtrlTreeView_EndUpdate($hTreeView) Do Until GUIGetMsg() = -3 Func ListFiles_ToTreeView($sSourceFolder, $hItem) Local $sFile ; Force a trailing \ If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\" ; Start the search Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*") ; If no files found then return If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Now run through the contents of the folder While 1 ; Get next match $sFile = FileFindNextFile($hSearch) ; If no more files then close search handle and return If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Check if a folder If @extended Then ; If so then call the function recursively ListFiles_ToTreeView($sSourceFolder & $sFile, _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile)) Else ; If a file than write path and name _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile) EndIf WEnd ; Close search handle FileClose($hSearch) EndFunc ;==>ListFiles_ToTreeView
      So i am searching for the exact same function just with
      GUICtrlCreateTreeViewItem
      instead of 
      _GUICtrlTreeView_AddChild
       
      Ps: i have a folder structure where i like to color each item green if a file only exist once and red if it exist more than once.

      Could someone help?
       
      Solution:

       
       
    • rm4453
      By rm4453
      Hello,
       
      I am currently writing a program that parses a massive table from a website, and need a way to add a progress bar while parsing.
      I am currently using the function _IETableWriteToArray($oObj, True) to parse the array. I need the progress bar to update as the table is parsed, not just at the end of the parsing.
      Any help at all would be very much appreciated!
       
      *EDIT --> The array I am left with after parsing is $array[0-50000][16]
    • FranckGr
      By FranckGr
      Hi
      Seams IniReadSectionNames does not show all Sections names (First one is missing ... [Site Information])
      My code
      Local $aSections=IniReadSectionNames($ThisIni)
      $ThisIni :
      [Site Information]
      Equipment ID:=539456593
      Customer Name:=CH
      Address: =-
      City State:=Town
      Country:=France
      Phone:=
      Zip Code:=24000
      Product Type:=Master
      [Computer]
      Computer Name=CHPRODFR
      Hardware Manufacturer=HP
      Hardware Model=ProLiant ML350 Gen9
      Processor=Intel(R) Xeon(R) CPU E5-2643 v3 @ 3.40GHz
      Number of memory modules=4
      Total Memory size=32 GB
      BIOS version=P92
      [Physical Disk Details]
      1=2.00 TB
      [Logical Disk Details]
      C:\=63.6 GB
      D:\=2062.1 GB
      F:\=872.8 GB
      [NIC Details]
      Embedded LOM 1 Port 1=00:10:6F:C5:FD:8E
      Hospital-LAN=70:10:6F:C5:FD:8E
      [Graphic Card Details]
      DriverDate=20150826
      DriverVersion=4.1.2.2
      Name=Matrox G200eh (HP) WDDM 1.2
      Status=OK
      VideoProcessor=Matrox G200eH
      [Memory Card Details]
      8192=752368-081
      8192=752368-081
      8192=752368-081
      8192=752368-081
      [Missing Components]
      [Non-standard Components]
      [Installed Hotfixes]
      $aSections
      Row|Col 0
      [0]|9
      [1]|Computer
      [2]|Physical Disk Details
      [3]|Logical Disk Details
      [4]|NIC Details
      [5]|Graphic Card Details
      [6]|Memory Card Details
      [7]|Missing Components
      [8]|Non-standard Components
      [9]|Installed Hotfixes
       
       
       
       
    • rudi
      By rudi
      Hello,
       
      from this posting of @Jos https://www.autoitscript.com/forum/topic/162005-getting-windows-users-account-type/?do=findComment&comment=1176831
      I can smoothly check, if a user is a *DIRECT* group member. Has anybody some code to check also, if a user is a *INDIRECT* member of a cascaded group construct?  Maybe with @Melba23 's AD UDF?
       
      The required rights are granted to group "Dept_B" User John is member of group "Dept_A" Group "Dept_A" is member of the group "Dept_B" So in the AD / NTFS FS environment John finally has the rights of both groups But when checking his "membership to group Dept_B" the result is "no member". The approach I can think of would be, to check all Group Members of group "Dept_B" whether they are of type group, then check again if "John" is member of than " 2nd level group"
      Func UserInGroup($InGroup,$ThisUser=@LogonDomain & "/" & @UserName) Local $objUser = ObjGet("WinNT://" & $ThisUser ) For $oGroup in $objUser.Groups If $oGroup.Name = $InGroup Then Return 1 EndIf Next Return 0 EndFunc Any suggestions appreciated, regards, Rudi.
×