Jump to content
Sign in to follow this  
polingkyle

Limit Dropdown Selection

Recommended Posts

polingkyle

I have a GUI with a drop-down menu (GUICtrlCreateCombo).  I'm trying to limit what a user can select in that drop-down.  Currently, the user sees the drop-down and can choose one of the options OR they can input anything else in that box.  I want to limit what can be chosen in that box to what is listed in the drop-down (shown below as "Dept 1" through "Dept 8").  This is very similar to Excel's data validation if that helps.  

$DeptNameLabel = GUICtrlCreateLabel("Department Name", 64, 128, 90, 17)
IF $DeptNameCurrent = "" Then
    $DeptName = GUICtrlCreateCombo("Choose from dropdown menu", 160, 128, 217, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
Else
    $DeptName = GUICtrlCreateCombo($DeptNameCurrent, 160, 128, 217, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
EndIf
GUICtrlSetData(-1, "Dept 1|Dept 2|Dept 3|Dept 4|Dept 5|Dept 6|Dept 7|Dept 8")
GUICtrlSetTip(-1, "Choose from dropdown")
GUISetState(@SW_SHOW)

Any help would be appreciated!  Thanks.

Share this post


Link to post
Share on other sites
polingkyle

Disregard.  I was able to find it by using a better search query on the forum.  For those interested:

$DeptNameLabel = GUICtrlCreateLabel("Department Name", 64, 128, 90, 17)
IF $DeptNameCurrent = "" Then
    $DeptName = GUICtrlCreateCombo("Choose from dropdown menu", 160, 128, 217, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
Else
    $DeptName = GUICtrlCreateCombo($DeptNameCurrent, 160, 128, 217, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
EndIf
GUICtrlSetData(-1, "Dept 1|Dept 2|Dept 3|Dept 4|Dept 5|Dept 6|Dept 7|Dept 8|")
GUICtrlSetTip(-1, "Choose from dropdown")
GUISetState(@SW_SHOW)

Thanks!

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  

×