cookiemonster Posted May 29, 2013 Share Posted May 29, 2013 Hi, So ive got a combo box that reads from an ini: Global $ini_save_file = @ScriptDir & "\config.ini" Global $Combo = GUICtrlCreateCombo("", 75, 15, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) _ReadComboOptions_FromINI() and ive got a label: $Label = GUICtrlCreateLabel("label text here", 16, 18, 50, 17) and the ini file looks like this: Combo_value1=1 Combo_value2=2 Combo_value3=3 Combo_value4=4 Combo_value5=5 Combo_value6=6 Combo_value7=7 Combo_value7=7a Combo_value7=7b Label_value1=Text1 Label_value2=Text2 Label_value3=Text3 Label_value4=Text4 Label_value5=Text5 Label_value6=Text6 Label_value7=Text7 Label_value7=Text7a Label_value7=text7b So what I want to happen is when I select a value in the combo box, is sets the label to the equivalant label value; EG: Combobox I select '1' and it would then automatically set Label to 'Text1' which its pulled from the ini file. Anyone got any idea how I would do this, spent several hours trying to figure it out but got nowhere at all Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 29, 2013 Moderators Share Posted May 29, 2013 quinnj09, I have rewritten your ini file to ease the problem - note that the "keys" of the Label section must match the "values" of the Combo section: [Combo] 1=1 2=2 3=3 4=4 5=5 6=6 7=7 8=7a 9=7b [Label] 1=Text1 2=Text2 3=Text3 4=Text4 5=Text5 6=Text6 7=Text7 7a=Text7a 7b=text7b Then this script works for me: #include <GUIConstantsEx.au3> #include <ComboConstants.au3> Global $ini_save_file = @ScriptDir & "\config.ini" Global $aLabel_Options = IniReadSection($ini_save_file, "Label") $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 75, 15, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) _ReadComboOptions_FromINI() $cLabel = GUICtrlCreateLabel("", 75, 200, 145, 25) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo $sCombo_Sel = GUICtrlRead($cCombo) $sLabel_Text = IniRead($ini_save_file, "Label", $sCombo_Sel, "Error") GUICtrlSetData($cLabel, $sLabel_Text) EndSwitch WEnd Func _ReadComboOptions_FromINI() $aIniRead = IniReadSection($ini_save_file, "Combo") If Not @Error Then $sCombo_List = "" For $i = 1 To $aIniRead[0][0] $sCombo_List &= "|" & $aIniRead[$i][1] Next GUICtrlSetData($cCombo, $sCombo_List) EndIf EndFunc Please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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