Jewtus Posted November 10, 2014 Share Posted November 10, 2014 I am trying to figure out what the best way of doing this is. I have several combo boxes that changed based on the previous combo box selection. I'd like to setup the ability to automatically predict the combo box input if you start typing. For example: Combo1 has the options for Yes|No|Maybe|So If Yes is selected Combo2 has This|Is|A|Test If no is selected Combo2 has Test|A|Is|This I'd like to make it so If I hit Y on the first combo box, it automatically predicts Yes and when I hit TAB, combo box 2 is updated with the Yes selection. I found this UDF: '?do=embed' frameborder='0' data-embedContent>> But it is for an edit control and uses a dictionary. Is there a way to predict text in the combobox based on what its data is already set to? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 10, 2014 Moderators Share Posted November 10, 2014 Jewtus,You need to use _GUICtrlComboBox_AutoComplete like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> Global $array_1[10] = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"] Global $array_2[5] = ["alpha", "beta", "gamma", "delta", "epsilon"] $hGUI = GUICreate("Example", 500, 200) $cCombo_Number = GUICtrlCreateCombo("", 50, 50, 200, 20) $cCombo_Alpha = GUICtrlCreateCombo("", 50, 100, 200, 20) $a = "" For $i = 0 To UBound($array_1) - 1 $a &= $array_1[$i] & "|" Next GUICtrlSetData($cCombo_Number, $a) $a = "" For $i = 0 To UBound($array_2) - 1 $a &= $array_2[$i] & "|" Next GUICtrlSetData($cCombo_Alpha, $a) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Edit_Changed($hControl) ; <<<<<<<<<<<<<<<<<<<<< _GUICtrlComboBox_AutoComplete($hControl) ; <<<<<<<<<<<<<<<<<<<<< EndFunc ;==>_Edit_Changed Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $iCode Case $CBN_EDITCHANGE Switch $iIDFrom Case $cCombo_Number _Edit_Changed($cCombo_Number) ; <<<<<<<<<<<<<<<<<<<<< Case $cCombo_Alpha _Edit_Changed($cCombo_Alpha) ; <<<<<<<<<<<<<<<<<<<<< EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMANDM23 232showtime 1 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...
jguinch Posted November 10, 2014 Share Posted November 10, 2014 (edited) _GUICtrlComboBox_AutoComplete does not work ? Edit : sorry, post in the same time as Melba ) Edited November 10, 2014 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Jewtus Posted November 10, 2014 Author Share Posted November 10, 2014 Ok, I got this to work, but I'm having some issues... (probably because I don't get how a lot of these examples Melba posts work... but I'm always able to get them functional in my scripts) Func _Edit_Changed($hControl) ; <<<<<<<<<<<<<<<<<<<<< _GUICtrlComboBox_AutoComplete($hControl) ; <<<<<<<<<<<<<<<<<<<<< EndFunc ;==>_Edit_Changed Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $iCode Case $CBN_EDITCHANGE Switch $iIDFrom Case $BL _Edit_Changed($BL) ; <<<<<<<<<<<<<<<<<<<<< Case $Issue _Edit_Changed($Issue) ; <<<<<<<<<<<<<<<<<<<<< Case $IssueDescript _Edit_Changed($IssueDescript) ; <<<<<<<<<<<<<<<<<<<<< EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND This is what I used and it does exactly what I want it to do with one caveat... I have sqlite query that updates the next entry box that doesn't seem to be working when I use the auto complete. EX: Case $BL $IssueList = GetRecords($sqlDB,"SELECT b.Description FROM LKUP_BusinessLine a join LKUP_Issue b on a.id=b.ClassID where a.Description='"&GUICtrlRead($BL)&"';") $stage = '' For $z=1 to UBound($IssueList) -1 $stage = $stage&"|"&$IssueList[$z][0] Next GUICtrlSetData($Issue,$stage) Case $Issue $IssueDescriptList = GetRecords($sqlDB,"SELECT b.Description FROM LKUP_Issue a join LKUP_IssueDescriptions b on a.issueid=b.issueID where a.Description='"&GUICtrlRead($Issue)&"';") $stage = '' For $z=1 to UBound($IssueDescriptList) -1 $stage = $stage&"|"&$IssueDescriptList[$z][0] Next GUICtrlSetData($IssueDescript,$stage) I'm not exactly sure how to mash these two functions together. I don't want the sqlite query to happen every single time I type a letter, just when I exit the combo box (to move to the next combo box). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 10, 2014 Moderators Share Posted November 10, 2014 Jewtus, because I don't get how a lot of these examples Melba posts workNever be afraid to ask - I am always happy to explain. just when I exit the combo boxIf I have understood you correctly, you need to look for the $CBN_KILLFOCUS message from the second combo and only then load the third combo:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> Global $array_1[5] = ["one", "two", "three", "four", "five"] Global $array_2[5] = ["alpha", "beta", "gamma", "delta", "epsilon"] Global $array_3[5] = ["tom", "dick", "harry", "bob", "alice"] $hGUI = GUICreate("Example", 500, 200) $cCombo_Number = GUICtrlCreateCombo("", 10, 10, 200, 20) $cCombo_Alpha = GUICtrlCreateCombo("", 10, 50, 200, 20) $cCombo_Name = GUICtrlCreateCombo("", 10, 90, 200, 20) Local $a = "", $b = "", $c = "" For $i = 0 To UBound($array_1) - 1 $a &= $array_1[$i] & "|" $b &= $array_2[$i] & "|" $c &= $array_3[$i] & "|" Next GUICtrlSetData($cCombo_Number, $a) GUICtrlSetData($cCombo_Alpha, $b) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Edit_Changed($hControl) _GUICtrlComboBox_AutoComplete($hControl) EndFunc ;==>_Edit_Changed Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $iCode Case $CBN_EDITCHANGE Switch $iIDFrom Case $cCombo_Number _Edit_Changed($cCombo_Number) Case $cCombo_Alpha _Edit_Changed($cCombo_Alpha) EndSwitch Case $CBN_KILLFOCUS ; Second combo has lost focus... Switch $iIDFrom Case $cCombo_Alpha GUICtrlSetData($cCombo_Name, $c) ; ...so load third combo EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMANDAs you can see, the third combo is empty until you have given and then removed focus from the second. This way you will never run the SQLite query until the second combo is complete. 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...
Jewtus Posted November 12, 2014 Author Share Posted November 12, 2014 Awesome! That is exactly what I needed. I'm leaving in the old case statements (in case I dont want to use the predictive text for some reason). Everyone on here is so great! Thanks fellas (especially Melba ) 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