Jump to content

Change Combobox Value Based on another control


Recommended Posts

First my apologies, I cme from a hardware and database background. I know enough about programig to be dangerous. I have setup Visual Forms and Controls in Access and have developed several Autoit applications (although I am sureI have junk in my code). Enough of that and I will get to the point,

I needed a little help on something I can’t figure out. I need the value of one combobox to change whenever I choose a value in another combo box.

In the following code I need it changed so that when I pick TWO from the first combobox that the value in the second combobox will change to second Choice and be displayed on the form while still open.

or of course when i pick ONE in the first combobox, I need the second box to display First Choice and likewise if I pick THREE in the first combo box that Third Choice will be displayed in the second combo box.

I created this cut down example that will assist in in a much more complex script I am working on.

Any ideas? I appreciate any help any of you can provide......

GUICreate("ComboBox GUI")

GUISetState()

$lblcombo1 = GUICtrlCreateLabel("Combo 1:", 10, 110, 80, 20)

$combo1Input = GUICtrlCreateCombo("One", 150, 110, 200, 20)

$lblcombo2 = GUICtrlCreateLabel("Combo 2:", 10, 140, 80, 20)

$combo2Input = GUICtrlCreateCombo("First Choice", 150, 140, 200, 20)

$cancel_button = GUICtrlCreateButton("Cancel", 260, 335, 68, 27)

GUICtrlSetData($combo1Input, "Two|Three", "One")

GUICtrlSetData($combo2Input, "Second Choice|Third Choice", "First Choice")

$bLoop = 1

While $bLoop = 1

Switch GUIGetMsg()

Case $cancel_button

Exit

Case Else

EndSwitch

WEnd

Link to comment
Share on other sites

I figured it out by doing the following,

#include <GUIConstantsEx.au3>

GUICreate("ComboBox GUI")

GUISetState()

$lblcombo1 = GUICtrlCreateLabel("Combo 1:", 10, 110, 80, 20)

$combo1Input = GUICtrlCreateCombo("One", 150, 110, 200, 20)

$lblcombo2 = GUICtrlCreateLabel("Combo 2:", 10, 140, 80, 20)

$combo2Input = GUICtrlCreateCombo("First Choice", 150, 140, 200, 20)

$cancel_button = GUICtrlCreateButton("Cancel", 260, 335, 68, 27)

GUICtrlSetData($combo1Input, "Two|Three", "One")

GUICtrlSetData($combo2Input, "Second Choice|Third Choice", "First Choice")

GUISetState()

While 1

Switch GUIGetMsg()

Case $GUI_EVENT_CLOSE

Exit

Case $combo1Input

Switch GUICtrlRead($combo1Input)

Case "One"

GUICtrlSetData($combo2Input,"First Choice")

Case "Two"

GUICtrlSetData($combo2Input,"Second Choice")

Case "Three"

GUICtrlSetData($combo2Input,"Third Choice")

EndSwitch

Case $cancel_button

Exit

EndSwitch

WEnd

Edited by TForgay
Link to comment
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
 Share

  • Recently Browsing   0 members

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