Sign in to follow this  
Followers 0
lrstndm

Set value Combobox

6 posts in this topic

Hi all,

I want to set the selected value in a combobox.

How can i do this?

For example:

I have a combobox with 5 values: 1, 2, 3, 4 and 5

When I click on the button I want that the combox select the number 4.

Thanks in advance,

lrstndm

Share this post


Link to post
Share on other sites



Please give your GUI code


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

$Form1 = GUICreate("Form1", 160, 65, 192, 124)
$Combo1 = GUICtrlCreateCombo("Number 1", 8, 8, 145, 25)
$Button1 = GUICtrlCreateButton("Button1", 77, 32, 75, 25)
GUISetState(@SW_SHOW)

GUICtrlSetData($Combo1, 'Number 2|Number 3|Number 4|Number 5')

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $Button1
; In here needs to come the code
; When you click on the button the combobox needs to select 'Number 2' value
EndSelect
WEnd

Edited by lrstndm

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>

$Form1 = GUICreate("Form1", 160, 65, 192, 124)
$Combo1 = GUICtrlCreateCombo("Number 1", 8, 8, 145, 25)
$Button1 = GUICtrlCreateButton("Button1", 77, 32, 75, 25)
GUISetState(@SW_SHOW)

GUICtrlSetData($Combo1, 'Number 2|Number 3|Number 4|Number 5')

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            ; When you click on the button the combobox needs to select 'Number 2' value
            _GUICtrlComboBox_SelectString($Combo1, 'Number 2')
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Thank you Zedna.

Thats it!

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