AlMax3000 Posted March 8, 2020 Posted March 8, 2020 Hi! how can I view the contents of an .ini file etc, on a combobox
argumentum Posted March 8, 2020 Posted March 8, 2020 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 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Subz Posted March 8, 2020 Posted March 8, 2020 IniReadSection to an array, then use _ArrayToString to copy the Key or Value to the combo box.
argumentum Posted March 9, 2020 Posted March 9, 2020 ..ok, @Subz will help you Nine 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
AlMax3000 Posted March 9, 2020 Author Posted March 9, 2020 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
AlMax3000 Posted March 9, 2020 Author Posted March 9, 2020 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 😦😅
Subz Posted March 9, 2020 Posted March 9, 2020 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 AlMax3000 1
AlMax3000 Posted March 9, 2020 Author Posted March 9, 2020 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
Subz Posted March 9, 2020 Posted March 9, 2020 You will need to post the Scite console error as the code above runs fine for me, I tested before posting. AlMax3000 1
AlMax3000 Posted March 9, 2020 Author Posted March 9, 2020 (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 March 9, 2020 by AlMax3000
Subz Posted March 9, 2020 Posted March 9, 2020 You can just use GuiCtrlRead($idComboBox) to read the selection in the ComboBox, example: Case $idComboBox MsgBox(4096, "", GUICtrlRead($idComboBox))
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now