Jump to content

Recommended Posts

Posted
38 minutes ago, Subz said:

IniReadSection in un array, quindi utilizzare _ArrayToString per copiare la chiave o il valore nella casella combinata.

yes I know, online is full of examples

Posted
41 minutes ago, argumentum said:

I'll help you @AlMax3000. Show me a sample .ini file and your sample code. You've been here since November, you know the drill :) 

wooow November 😦😅

Posted

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

 

Posted
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

Posted (edited)
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...