Jump to content
Sign in to follow this  
Idea

Populating ListView from a .ini

Recommended Posts

exactly what this does.... can read from seond ini also

Global $macrolist[10], $macrolistdata[50]
#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>
; need this for my testing..... ok???
Dim $Location = "C:\Temp\sections.ini"
Dim $Location2 = "C:\Temp\pagedetails.ini"

;===================================> GUI <=======================================

GUICreate("Macro v1.0", 400, 460)
$filemenu = GUICtrlCreateMenu("File")
$optionsmenu = GUICtrlCreateMenu("Options")
$helpmenu = GUICtrlCreateMenu("?")
$fileitem = GUICtrlCreateMenuItem("Exit", $filemenu)
$button = GUICtrlCreateButton("New", 335, 15, 60)

$btnsave = GUICtrlCreateButton("Save", 335, 145, 60)


$treeview = GUICtrlCreateTreeView(6, 6, 200, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)
$sections = IniReadSectionNames($Location)
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $sections[0]
        $keys = IniReadSection($Location, $sections[$i])
        $item = GUICtrlCreateTreeViewItem($sections[$i], $treeview)
        For $x = 1 To $keys[0][0]
            GUICtrlCreateTreeViewItem($keys[$x][0], $item)
        Next
    Next
EndIf

GUISetState()
;================================> End GUI <======================================


While 1
    $msg = GUIGetMsg()
    
    Select
    ;Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton
        Case $msg = $gui_event_close
            ExitLoop
        Case $msg = $button
            Call("Set_PageDetails")
            
    EndSelect
    
    Sleep(10)
    
WEnd


; ------------------------------- Functions --------------------------------

Func Set_PageDetails()
; read the selection
    $item1 = GUICtrlRead($treeview)
    $item2 = GUICtrlRead($item1, 1)
    
; read the ini portion rerquested
    $name = IniRead($Location2, $item2[0], "Name", "NotFound")
    $page = IniRead($Location2, $item2[0], "Page", "NotFound")
    $topic = IniRead($Location2, $item2[0], "Topic", "NotFound")
    $status = IniRead($Location2, $item2[0], "UserStatus", "NotFound")
    $editstatus = IniRead($Location2, $item2[0], "EditStatus", "NotFound")
    $duedate = IniRead($Location2, $item2[0], "Due", "NotFound")
    
; display the info just read
    GUICtrlCreateLabel("Assigned To: ", 10, 280, 100, 20, 0x1000)
    GUICtrlCreateInput($name, 10, 300, 100, 20)
    GUICtrlCreateLabel("Page #: ", 120, 280, 100, 20, 0x1000)
    GUICtrlCreateInput($page, 120, 300, 100, 20)
    GUICtrlCreateLabel("Topic: ", 10, 330, 100, 20, 0x1000)
    GUICtrlCreateInput($topic, 10, 350, 100, 20)
    GUICtrlCreateLabel("Status: ", 120, 330, 100, 20, 0x1000)
    GUICtrlCreateInput($status, 120, 350, 100, 20)
    GUICtrlCreateLabel("EditStatus: ", 10, 380, 100, 20, 0x1000)
    GUICtrlCreateInput($editstatus, 10, 400, 100, 20)
    GUICtrlCreateLabel("DUE: ", 120, 380, 100, 20, 0x1000)
    GUICtrlCreateInput($duedate, 120, 400, 100, 20)
EndFunc  ;==>Set_PageDetails

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

data.ini contains:

[student1]

1=5242

2=2023

3=3984

[student2]

1=2242

2=3493

3=3894

I'd like the list view to look like this:

-student1

---1

---2

---3

-student2

---1

---2

---3

Then when one of the sub items is clicked for the value to be populated in a label. So if I clicked 1 under student1 the label would read 5242.

Doing this is easy enough with static data as the example in the autoit helpfile outlines for GUICtrlCreateListViewItem. Would someone mind providing the code to do this little example? I know it's a bit of work so thank you in advance.

Here's the GUI code:

#include <GUIConstants.au3>
GUICreate("Form1", 312, 191, 302, 218, $WS_OVERLAPPEDWINDOW)
$TreeView1 = GUICtrlCreateTreeView(8, 16, 153, 169, -1)
$Label1 = GUICtrlCreateLabel("Label1", 176, 16, 32, 13)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    EndSelect
WEnd
Exit
i've seen a few topics along the same lines, populating trees and combo boxes from ini's in the last few days, you may want to check them out; i believe full code solutions were provided in both cases.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...