aa2zz6

Linking Multiple GUICtrlSetData's Help

4 posts in this topic

If the user types in "Tap Tee" the first combo box how would I make the second combo box automatically choose item number "10010"?

 

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $cCombo1, $cCombo2
Global $sFunction = "; Function Name:    "

_Main()

Func _Main()

    ; Create GUI
    GUICreate("MapInfo Auto Complete", 190, 296)

    Local $iWidthCell = 70
    GUICtrlCreateLabel("Component:", 5, 10, $iWidthCell) ; first cell 70 width
    $cCombo1 = GUICtrlCreateCombo("", 65, 10, 100, 296)
    GUICtrlSetData(-1, "TAP TEE|TEE|EFV|EF COLLAR|CURB VALVE|CAP|VALVE BOX")

    GUICtrlCreateLabel("Item_no:", 5, 40) ; next line and next cell
    $cCombo2 = GUICtrlCreateCombo("", 65, 42, 100, 296)
    GUICtrlSetData(-1, "55010|36018|24121")
    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Func _Edit_Changed($cCombo)
    _GUICtrlComboBox_AutoComplete($cCombo)
EndFunc   ;==>_Edit_Changed

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)

    #forceref $hWnd, $iMsg, $ilParam

    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    If $iCode = $CBN_EDITCHANGE Then
        Switch $iIDFrom
            Case $cCombo1
                _Edit_Changed($cCombo1)
            Case $cCombo2
                _Edit_Changed($cCombo2)
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this :

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $cCombo1, $cCombo2
Global $sFunction = "; Function Name:    "

_Main()

Func _Main()

    ; Create GUI
    GUICreate("MapInfo Auto Complete", 190, 296)

    Local $iWidthCell = 70
    GUICtrlCreateLabel("Component:", 5, 10, $iWidthCell) ; first cell 70 width
    $cCombo1 = GUICtrlCreateCombo("", 65, 10, 100, 296)
    GUICtrlSetData(-1, "TAP TEE|TEE|EFV|EF COLLAR|CURB VALVE|CAP|VALVE BOX")

    GUICtrlCreateLabel("Item_no:", 5, 40) ; next line and next cell
    $cCombo2 = GUICtrlCreateCombo("", 65, 42, 100, 296)
    GUICtrlSetData(-1, "55010|36018|24121")
    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until user exits
    Do

    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Func _Edit_Changed($cCombo)
    _GUICtrlComboBox_AutoComplete($cCombo)
EndFunc   ;==>_Edit_Changed

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)

    #forceref $hWnd, $iMsg, $ilParam

    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    If $iCode = $CBN_EDITCHANGE Then
        Switch $iIDFrom
            Case $cCombo1
                _Edit_Changed($cCombo1)
                $enter = GUICtrlRead($cCombo1)
                If StringCompare($enter, "TAP TEE") = 0 Then
                    GUICtrlSetData($cCombo2, "")
                    GUICtrlSetData($cCombo2, "55010|36018|24121|10010", "10010")
                EndIf


            Case $cCombo2
                _Edit_Changed($cCombo2)
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Its your code i just changed a little bit :)

Edited by Surya

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Share this post


Link to post
Share on other sites

Thanks Surya, the code change works perfectly!

Share this post


Link to post
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