Sign in to follow this  
Followers 0
LurchMan

ListView Help

3 posts in this topic

Hey Everyone -

I'm working on building a GUI that gets info from and INI file - pretty straight forward except I can't get it to update correctly. I want Section name in first column, and each key for that section in the column next to the previous one in the same row (if that makes sense). Any help will greatly be appreciated.

INI File:

[01 Daily]
Status=Running
Current Step=001
Errors=0
[02 Daily]
Status=Running
Current Step=010
Errors=2

Script:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>

Opt("GUIOnEventMode", 1)

Global $sINIFile = @ScriptDir & "\job info.ini"
Global $ListView
#Region ### START Koda GUI section ### Form=
$jobstatus = GUICreate("Job Status", 847, 331, 192, 114)
$menu = GUICtrlCreateMenu("File")
$refresh = GUICtrlCreateMenuItem("Refresh (F5)", $menu)
GUICtrlSetOnEvent(-1, "_Refresh")
$exit = GUICtrlCreateMenuItem("Exit", $menu)
GUICtrlSetOnEvent(-1, "jobstatusClose")
GUISetOnEvent($GUI_EVENT_CLOSE, "jobstatusClose")
$ListView = GUICtrlCreateListView("Job Name|Status|Current Step|Errors", 8, 0, 826, 302, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$LVS_SORTASCENDING,$LVS_SORTDESCENDING,$LVS_AUTOARRANGE))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 75)
GUISetState(@SW_SHOW)
Dim $jobstatus_AccelTable[1][2] = [["{F5}", $refresh]]
GUISetAccelerators($jobstatus_AccelTable)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func jobstatusClose()
    Exit
EndFunc

Func _Refresh()
    Local $sData, $iCnt = 1
    $aSections = IniReadSectionNames ($sINIFile)
    For $n = 1 To $aSections[0]
        $aData = IniReadSection ($sINIFile, $aSections[$n])
        $iCol = _GUICtrlListView_AddItem($ListView, $aSections[$n])
        For $a = 2 To $aData[0][0]
            $iCnt +=1
            _GUICtrlListView_AddSubItem($ListView, $iCol, $aData[$n][1], $iCnt)
        Next
        $iCnt = 1
    Next
EndFunc

Result is attached image.

post-44385-1288037874601_thumb.jpg


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites



Your bizzare use of $iCol when you mean "row" or "item" and the strange $iCnt counter is confusing the issue. Try this:

Func _Refresh()
    Local $aSections, $iNewRow, $aData
    $aSections = IniReadSectionNames($sINIFile)
    For $iSec = 1 To $aSections[0]
        $iNewRow = _GUICtrlListView_AddItem($ListView, $aSections[$iSec])
        $aData = IniReadSection($sINIFile, $aSections[$iSec])
        For $iCol = 1 To $aData[0][0]
            _GUICtrlListView_AddSubItem($ListView, $iNewRow, $aData[$iCol][1], $iCol)
        Next
    Next
EndFunc   ;==>_Refresh

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Ok, That makes sense. I know my crazy logic isn't always the easiest way (and usually complicates it more) but it works for what I need.

Thank you for your help!


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

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