Jump to content
Sign in to follow this  

Combobox Change Value

Recommended Posts

Is there a way to dynamically change a value in a drop down box.

For instance the drop down box has the following options to select

  • Setup
  • Mode-Dual
  • Copy
  • Filter

When the person selects the Option -> Mode-Dual <- Event handle does a few things but also changes the list to look like ->

  • Setup
  • Mode-Single
  • Copy
  • Filter

Then if the person would choose Mode-Single it would then change back to Mode-Dual.

I have looked over the forums and internet and have not found anything that helps me accomplish this.

Any pointers would be appreciated (Don't really want to do a control destroy and create it again if I can avoid that).


Share this post

Link to post
Share on other sites

Thanks Johnone

That is only a part of it.

Need to take the entire contents of the dropdown box.

Do a string replace

Then Empty the contents of the control

Then add the data back into the control

Sample code below:

$tmpMainMenuOpt = StringReplace($tmpMainMenuOpt, "Mode-Dual", "Mode-Single")
GUICtrlSetData($cmbMainOpt, $tmpMainMenuOpt)

Share this post

Link to post
Share on other sites


You are overcomplicating things - using GUICtrlSetData with a leading "|" will replace the data automatically: ;)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

$sData_Dual = "|Setup|Mode-Dual|Copy|Filter"     ; Note leading "|"
$sData_Single = "|Setup|Mode-Single|Copy|Filter"

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData($cCombo, $sData_Dual)
$fDual = True ; Set a flag


While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        Case $cCombo
            Switch GUICtrlRead($cCombo)
                Case "Setup"
                    MsgBox($MB_SYSTEMMODAL, "Selected", "Setup")
                Case "Copy"
                    MsgBox($MB_SYSTEMMODAL, "Selected", "Copy")
                Case "Filter"
                    MsgBox($MB_SYSTEMMODAL, "Selected", "Filter")
                Case Else
                    $fDual = Not $fDual ; Toggle the flag
                    If $fDual Then
                        GUICtrlSetData($cCombo, $sData_Dual)
                        GUICtrlSetData($cCombo, $sData_Single)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

Thanks for the information about using the "|". However I still will do the string replace cause I suspect this dropdown in the future will have other options to swap in and out. Thanks again :)

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...