Jump to content

GUICtrlCreateListView from Ini File


ajit
 Share

Recommended Posts

Hi

I want to create GUICtrlCreateListView (with three items) from Ini file using section, key, and value as items in a serial order as the sections, keys, and values appear in the ini file.

Is it possible?

Please help me

Ajit

Link to comment
Share on other sites

If i right understand you, you've an INI like this:

[sec1]
key1_1=val1_1
key2_1=val2_1

[sec2]
key1_2=val1_2

[sec3]
key1_3=val1_3

And you want an ListView like following:

sec1 val1_1 key1_1

sec1 val2_1 key2_1

sec2 val1_2 key1_2

sec3 val1_3 key1_3

This is the way:

$INI = 'Path to ini-file'
$sItem = ''
$aSections = IniReadSectionNames($INI)
For $i = 1 To UBound($aSections) -1
    $aKeys = IniReadSection($aSections[$i])
    For $j = 1 To UBound($aKeys) -1
        $sItem &= $aSections[$i] & '|' & $aKeys[$j][0] & '|' & $aKeys[$j][1] & @LF
    Next
Next
$aItem = StringSplit($sItem, @LF)
For $i = 1 To UBound($aItem) -1
    GUICtrlCreateListViewItem($aItem[$i], $listviewID)
Next
Edited by BugFix

Best Regards BugFix  

Link to comment
Share on other sites

$Ini = "C:\SomePath\SomeFile.ini"
$aSecs = IniReadSectionNames($Ini)
$Main = GUICreate("Test GUI")
$Lv = GUICtrlCreateListView("Section|Key|Value",10,10,300, 300)
For $I = 1 To Ubound($aSecs) -1
   $aVals = IniReadSection($Ini, $aSecs[$I])
   For $X = 1 To Ubound($aVals) -1
      $sVal = $aSecs[$i] & "|" & $aVals[$x][0] & "|" & $aVals[$x][1]
      GUICtrlCreateListViewItem($sVal, $Lv)
   Next
Next
GUISetState()
While 1
   If GUIGetMsg() = -3 Then Exit
Wend

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

$Ini = "C:\SomePath\SomeFile.ini"
$aSecs = IniReadSectionNames($Ini)
$Main = GUICreate("Test GUI")
$Lv = GUICtrlCreateListView("Section|Key|Value",10,10,300, 300)
For $I = 1 To Ubound($aSecs) -1
   $aVals = IniReadSection($Ini, $aSecs[$I])
   For $X = 1 To Ubound($aVals) -1
      $sVal = $aSecs[$i] & "|" & $aVals[$x][0] & "|" & $aVals[$x][1]
      GUICtrlCreateListViewItem($sVal, $Lv)
   Next
Next
GUISetState()
While 1
   If GUIGetMsg() = -3 Then Exit
Wend

@GEOSoft

Thanks so much.

That was exactly the way i wanted it.

Ajit

Link to comment
Share on other sites

If i right understand you, you've an INI like this:

[sec1]
key1_1=val1_1
key2_1=val2_1

[sec2]
key1_2=val1_2

[sec3]
key1_3=val1_3

And you want an ListView like following:

sec1 val1_1 key1_1

sec1 val2_1 key2_1

sec2 val1_2 key1_2

sec3 val1_3 key1_3

This is the way:

$INI = 'Path to ini-file'
$sItem = ''
$aSections = IniReadSectionNames($INI)
For $i = 1 To UBound($aSections) -1
    $aKeys = IniReadSection($aSections[$i])
    For $j = 1 To UBound($aKeys) -1
        $sItem &= $aSections[$i] & '|' & $aKeys[$j][0] & '|' & $aKeys[$j][1] & @LF
    Next
Next
$aItem = StringSplit($sItem, @LF)
For $i = 1 To UBound($aItem) -1
    GUICtrlCreateListViewItem($aItem[$i], $listviewID)
Next

@BugFix

Thanks very much for your help.

Ajit

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...