Jump to content

Show .ini to Combobox


Recommended Posts

Going to assume your English isn't your first language, because your response didn't really make sense, "yes I know, online is full of examples" implies you already know the answer to the original OP.  To save banter here is a working example of what I mentioned above.

Combo.ini

[ComboBox]
ComboBox1 = You chose ComboBox1
ComboBox2 = You chose ComboBox2
ComboBox3 = You chose ComboBox3
#include <Array.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $aCombo = IniReadSection(@ScriptDir & "\Combo.ini", "ComboBox")
    _ArrayDelete($aCombo, 0)    ;~ Delete first column count
    GUICreate("Example", 300, 200)
    Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 185, 20)
    GUICtrlSetData($idComboBox, _ArrayToString($aCombo, "|", -1, -1, "|", 0, 0), $aCombo[0][0])
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idComboBox
                $iCombo = _GUICtrlComboBoxEx_GetCurSel($aCombo)
                MsgBox(4096, "", $aCombo[$iCombo][1])
        EndSwitch
    WEnd
    GUIDelete()
EndFunc

 

Link to comment
Share on other sites

3 minutes ago, Subz said:

Going to assume your English isn't your first language, because your response didn't really make sense, "yes I know, online is full of examples" implies you already know the answer to the original OP.  To save banter here is a working example of what I mentioned above.

Combo.ini

[ComboBox]
ComboBox1 = You chose ComboBox1
ComboBox2 = You chose ComboBox2
ComboBox3 = You chose ComboBox3
#include <Array.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $aCombo = IniReadSection(@ScriptDir & "\Combo.ini", "ComboBox")
    _ArrayDelete($aCombo, 0)    ;~ Delete first column count
    GUICreate("Example", 300, 200)
    Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 185, 20)
    GUICtrlSetData($idComboBox, _ArrayToString($aCombo, "|", -1, -1, "|", 0, 0), $aCombo[0][0])
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idComboBox
                $iCombo = _GUICtrlComboBoxEx_GetCurSel($aCombo)
                MsgBox(4096, "", $aCombo[$iCombo][1])
        EndSwitch
    WEnd
    GUIDelete()
EndFunc

 

error in line 12

Link to comment
Share on other sites

2 hours ago, Subz said:

You will need to post the Scite console error as the code above runs fine for me, I tested before posting.

working ok! runs fine even for me

#include <Array.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>

Example()
Func Example()
    $sFileName = (@ScriptDir & "\Combo.ini")
    If NOT FileExists(@ScriptDir & "\Combo.ini") Then
    IniWrite($sFileName, "ComboBox", "ComboBox1","You chose ComboBox1")
    EndIf

    Local $aCombo = IniReadSection(@ScriptDir & "\Combo.ini", " ComboBox ")
    _ArrayDelete($aCombo, 0)    ;~ Delete first column count
    GUICreate("Example", 300, 200)
    Local $idComboBox = GUICtrlCreateCombo(" ", 10, 10, 185, 20)
    GUICtrlSetData($idComboBox, _ArrayToString($aCombo, "|", -1, -1, "|", 0, 0), $aCombo[0][0]) 
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idComboBox
                $iCombo = _GUICtrlComboBoxEx_GetCurSel($aCombo)
                MsgBox(4096, "", $aCombo[$iCombo][1])               
        EndSwitch
    WEnd
    GUIDelete()
EndFunc

now no error if it cannot find the file

my problem that I would like to display in the combobox: You chose ComboBox1 no ComboBox1 without reversing the names example: You chose ComboBox1 = ComboBox1 

ComboBox1 = You chose ComboBox1

 

Edited by AlMax3000
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...