Jump to content

Validate combobox


MaartenDuits
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.
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...