Sign in to follow this  
Followers 0
lyledg

Populate A Combo Box From A Readsectionnames Ini File?

3 posts in this topic

Guys

How can i do this...I have a *.ini file that I want to use the sectionnames from a ini file and populate a combo box

I know this must be simple, but I am completely blank for the moment :think:

#include <GUIConstants.au3>
#include <GuiCombo.au3>


Local $IniFile = @ScriptDir & "\ip.ini"
Local $msg
Dim $VendorComborslt
; == GUI generated with Koda ==);
$Form1 = GUICreate("Application Chooser", 283, 301, 210, 142)
GUISetIcon("D:\005.ico")
$PageControl1 = GUICtrlCreateTab(8, 8, 268, 256, $WS_GROUP)
$TabSheet1 = GUICtrlCreateTabItem("Application Chooser")
GUICtrlCreateLabel("Vendor:", 24, 48, 41, 17)
GUICtrlCreateLabel("Application name:", 24, 104, 88, 17)
$VendorCombo = GUICtrlCreateCombo("", 24, 72, 201, 21)
$AppnameCombo = GUICtrlCreateCombo("", 24, 128, 201, 21)
GUICtrlCreateLabel("Specify a version number:", 24, 160, 126, 17)
$Vercombo = GUICtrlCreateCombo("", 24, 184, 201, 21)
$TabSheet2 = GUICtrlCreateTabItem("Add new Application")
GUICtrlCreateTabItem("")
$Okbtn = GUICtrlCreateButton("&OK", 110, 272, 75, 25)
$Cancelbtn = GUICtrlCreateButton("&Cancel", 198, 272, 75, 25)
GUISetState(@SW_SHOW)
_ReadIniFile()

While 1
    $msg = GUIGetMsg()
    Select
        
        Case $msg = $Okbtn
            Writeini()
        Case $msg = $Cancelbtn
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;;;;;
    EndSelect
WEnd



Func Writeini()
    
    $VendorComborslt = GUICtrlRead($VendorCombo)
    $AppnameComborslt = GUICtrlRead($AppnameCombo)
    $Vercomborslt = GUICtrlRead($Vercombo)
    
    $VendorComboread = GUICtrlRead($VendorCombo) <> ""
    $AppnameComboread = GUICtrlRead($AppnameCombo) <> ""
    $Vercomboread = GUICtrlRead($Vercombo) <> ""
    
    
;Check to see if all the inout fields are populated, if not return an error
    Select
        
        Case $VendorComboread = 0
            MsgBox(16, "Error!", "Vendor name is missing")
            Return
        Case $AppnameComboread = 0
            MsgBox(16, "Error!", "App name is missing")
            Return
        Case $Vercomboread = 0
            MsgBox(16, "Error!", "Version number is missing")
            Return          
    EndSelect
        
    IniWrite($IniFile, $VendorComborslt , $AppnameComborslt, $Vercomborslt) 
    
        If(StringLen(GUICtrlRead($VendorCombo)) > 0) Then
            $i_index =_GUICtrlComboInsertString($VendorCombo,_GUICtrlComboGetCurSel($VendorCombo),GUICtrlRead($VendorCombo))
            ;GUICtrlSetData($Status,"String Inserted At Index: " & $i_index)
            EndIf
    
        
    EndFunc  ;==>Writeini   
    
Func _ReadIniFile()
    
    Local $inientry = IniReadSectionNames ($IniFile)
    If Not IsArray($inientry) Then
        MsgBox(0, "", "No Entry")
    Else
        For $i = 1 To $inientry[0]
        MsgBox(4096, "", $inientry[$i])
        GUICtrlSetData ($Vercombo, $inientry)
    Next

    EndIf
EndFunc ;==>_ReadIniFile

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Worked with Single arrays here for that.. but concept can be enrolled into yours...

http://www.autoitscript.com/forum/index.ph...867&hl=Populate

Worked with IniReadSection() with GUICtrlCreateListView() and the concept can be switched to combo boxes also (example with 2d array): http://www.autoitscript.com/forum/index.ph...ndpost&p=167638

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanx mate! Was a great help!

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