Sign in to follow this  
Followers 0
Gokul

Not able to select a value form combobox

6 posts in this topic

#1 ·  Posted (edited)

Hi,

My application have a combobox with values 'Test', 'Test1' and 'Test3' in it. But, when i give the below script the dropdown list is shown but 'Test1' is not selected from the dropdown list of the combobox.

ControlCommand("Title", "", "[NAME:controlname]", "ShowDropDown")
ControlCommand("Title", "", "[NAME:controlname]", "SelectString", 'Test1')

How to select and set a value from the dropdown list to combobox.

Edited by Gokul

Share this post


Link to post
Share on other sites



Gokul,

  Not really clear on what your going for...

If this is your own GUI you dont need ControlCommand to select & manipulate items rather something like:

_GUICtrlComboBox_SetEditSel  etc...

Bill

Iam new to Autoit. Can you give me a sample code on how to use _GUICtrlCombobox_SetEditSel.

Share this post


Link to post
Share on other sites

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

Global $iMemo

_Main()

Func _Main()
    Local $aSel, $hCombo

    ; Create GUI
    GUICreate("ComboBox Set Edit Sel", 400, 296)
    $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; Add files
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; Select Item
    _GUICtrlComboBox_SetCurSel($hCombo, 2)

    ; Set Edit Sel
    _GUICtrlComboBox_SetEditSel($hCombo, 0, 4)

    ; Get Edit Sel
    $aSel = _GUICtrlComboBox_GetEditSel($hCombo)
    MemoWrite(StringFormat("Edit Sel: %d - %d", $aSel[0], $aSel[1]))

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Share this post


Link to post
Share on other sites

Autoit help is user friendly. try it out :) i am also new to autoit

Share this post


Link to post
Share on other sites

Try using

$hWnd=ControlGetHandle("Title", "", "[NAME:controlname]")
_GUICtrlComboBox_SelectString($hWnd, "Test1")

And also looks like the dropdown item "Test1" is not specified properly in your first post. "Test1" should be put inside double quotes not single.

ControlCommand("Title", "", "[NAME:controlname]", "SelectString", "Test1")

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