Sign in to follow this  
Followers 0
MaartenDuits

Validate combobox

3 posts in this topic

Hi,

I created a combobox, what i am wondering is how can i validate if the value is in the combobox?

For example:

Combo has possible values A, B and C

If user enters D how can i validate if the D is one of the possible values?

Hope somebody can help me.

Thx in advance.

Kind regards,

Maarten.


Kind regards,Maarten

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

First,

You use GuiCtrlRead() to read the value of the Combobox. Then you can compare the value read with whatever else and then perform an action or something.

2nd,

If your ComboBox is not static I would make it so. Don't allow the user to input any data themselves into the ComboBox. Usually when I make a ComboBox I only want them to have the choices that I put there.

So create the combobox with the $CBS_DROPDOWNLIST style so that it's readonly to the user.

e.g.

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $msg
    GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered

    GUICtrlCreateCombo("item1", 10, 10, "", "", $CBS_DROPDOWNLIST) ; create first item
    GUICtrlSetData(-1, "item2|item3", "item3") ; add other item snd set a new default

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example
Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Hello EndFunc,

Thx for the reply. This is exactly what i was looking for!! Thx again.

Maarten.


Kind regards,Maarten

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  
Followers 0