Jump to content

Select another item in my own Combobox


Recommended Posts

Good morning,

I've been checking the help file and many forums but I haven't found the command to do what I need.

I have a Combobox in my own GUI and once a function begins I need it select another option in my own Combobox. All options are already set in the Combobox.

Thank you very much for helping me

Link to comment
Share on other sites

I found this looking for the answer myself. I've found this under GUICtrlSetData()

For Combo or List control :

If the "data" corresponds to an already existing entry it is set as the default.

If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed.

Link to comment
Share on other sites

Ok, I solved my problem but thank you anyway.

I am writing you here the solution I used:

Global $items, $msg, $comb, $bot1, $bot2

GUICreate("GUI combo", 180, 110)

$items = "|item1|item2|item3"

$comb = GUICtrlCreateCombo("", 10, 10, 160)

GUICtrlSetData(-1, $items, "item3")

$bot1 = GuiCtrlCreateButton('Selecciona "item1"', 10, 40)

$bot2 = GuiCtrlCreateButton("Selecciona segundo elemento", 10, 70)

GUISetState()

While 1

$msg = GUIGetMsg()

Switch $msg

case $GUI_EVENT_CLOSE

ExitLoop

case $bot1

;GUICtrlSetData($comb, $items, "item1")

GUICtrlSendMsg($comb, $CB_SELECTSTRING, -1, "item1") ; Selecciona por texto

case $bot2

GUICtrlSendMsg($comb, $CB_SETCURSEL, 1, 0) ; Selecciona por posiciĆ³n (0 = primer elemento)

EndSwitch

WEnd

Edited by mitchito
Link to comment
Share on other sites

Help file >> _GUICtrlComboBox_SetCurSel.

UDF List:

Ā 
_AdapterConnections() ā€¢ _AlwaysRun() ā€¢ _AppMon() ā€¢ _AppMonEx() ā€¢ _ArrayFilter/_ArrayReduce ā€¢ _BinaryBin() ā€¢ _CheckMsgBox() ā€¢ _CmdLineRaw() ā€¢ _ContextMenu() ā€¢ _ConvertLHWebColor()/_ConvertSHWebColor() ā€¢ _DesktopDimensions() ā€¢ _DisplayPassword() ā€¢ _DotNet_Load()/_DotNet_Unload() ā€¢ _Fibonacci() ā€¢ _FileCompare() ā€¢ _FileCompareContents() ā€¢ _FileNameByHandle() ā€¢ _FilePrefix/SRE() ā€¢ _FindInFile() ā€¢ _GetBackgroundColor()/_SetBackgroundColor() ā€¢ _GetConrolID() ā€¢ _GetCtrlClass() ā€¢ _GetDirectoryFormat() ā€¢ _GetDriveMediaType() ā€¢ _GetFilename()/_GetFilenameExt() ā€¢ _GetHardwareID() ā€¢ _GetIP() ā€¢ _GetIP_Country() ā€¢ _GetOSLanguage() ā€¢ _GetSavedSource() ā€¢ _GetStringSize() ā€¢ _GetSystemPaths() ā€¢ _GetURLImage() ā€¢ _GIFImage() ā€¢ _GoogleWeather() ā€¢ _GUICtrlCreateGroup() ā€¢ _GUICtrlListBox_CreateArray() ā€¢ _GUICtrlListView_CreateArray() ā€¢ _GUICtrlListView_SaveCSV() ā€¢ _GUICtrlListView_SaveHTML() ā€¢ _GUICtrlListView_SaveTxt() ā€¢ _GUICtrlListView_SaveXML() ā€¢ _GUICtrlMenu_Recent() ā€¢ _GUICtrlMenu_SetItemImage() ā€¢ _GUICtrlTreeView_CreateArray() ā€¢ _GUIDisable() ā€¢ _GUIImageList_SetIconFromHandle() ā€¢ _GUIRegisterMsg() ā€¢ _GUISetIcon() ā€¢ _Icon_Clear()/_Icon_Set() ā€¢ _IdleTime() ā€¢ _InetGet() ā€¢ _InetGetGUI() ā€¢ _InetGetProgress() ā€¢ _IPDetails() ā€¢ _IsFileOlder() ā€¢ _IsGUID() ā€¢ _IsHex() ā€¢ _IsPalindrome() ā€¢ _IsRegKey() ā€¢ _IsStringRegExp() ā€¢ _IsSystemDrive() ā€¢ _IsUPX() ā€¢ _IsValidType() ā€¢ _IsWebColor() ā€¢ _Language() ā€¢ _Log() ā€¢ _MicrosoftInternetConnectivity() ā€¢ _MSDNDataType() ā€¢ _PathFull/GetRelative/Split() ā€¢ _PathSplitEx() ā€¢ _PrintFromArray() ā€¢ _ProgressSetMarquee() ā€¢ _ReDim() ā€¢ _RockPaperScissors()/_RockPaperScissorsLizardSpock() ā€¢ _ScrollingCredits ā€¢ _SelfDelete() ā€¢ _SelfRename() ā€¢ _SelfUpdate() ā€¢ _SendTo() ā€¢ _ShellAll() ā€¢ _ShellFile() ā€¢ _ShellFolder() ā€¢ _SingletonHWID() ā€¢ _SingletonPID() ā€¢ _Startup() ā€¢ _StringCompact() ā€¢ _StringIsValid() ā€¢ _StringRegExpMetaCharacters() ā€¢ _StringReplaceWholeWord() ā€¢ _StringStripChars() ā€¢ _Temperature() ā€¢ _TrialPeriod() ā€¢ _UKToUSDate()/_USToUKDate() ā€¢ _WinAPI_Create_CTL_CODE() ā€¢ _WinAPI_CreateGUID() ā€¢ _WMIDateStringToDate()/_DateToWMIDateString() ā€¢ Au3 script parsing ā€¢ AutoIt Search ā€¢ AutoIt3 Portable ā€¢ AutoIt3WrapperToPragma ā€¢ AutoItWinGetTitle()/AutoItWinSetTitle() ā€¢ Coding ā€¢ DirToHTML5 ā€¢ FileInstallr ā€¢ FileReadLastChars() ā€¢ GeoIP database ā€¢ GUI - Only Close Button ā€¢ GUI Examples ā€¢ GUICtrlDeleteImage() ā€¢ GUICtrlGetBkColor() ā€¢ GUICtrlGetStyle() ā€¢ GUIEvents ā€¢ GUIGetBkColor() ā€¢ Int_Parse() & Int_TryParse() ā€¢ IsISBN() ā€¢ LockFile() ā€¢ Mapping CtrlIDs ā€¢ OOP in AutoIt ā€¢ ParseHeadersToSciTE() ā€¢ PasswordValid ā€¢ PasteBin ā€¢ Posts Per Day ā€¢ PreExpand ā€¢ Protect Globals ā€¢ Queue() ā€¢ Resource Update ā€¢ ResourcesEx ā€¢ SciTE Jump ā€¢ Settings INI ā€¢ SHELLHOOK ā€¢ Shunting-Yard ā€¢ Signature Creator ā€¢ Stack() ā€¢ Stopwatch() ā€¢ StringAddLF()/StringStripLF() ā€¢ StringEOLToCRLF() ā€¢ VSCROLL ā€¢ WM_COPYDATA ā€¢ More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I'm not sure you got the GUICtrlSetData function to work properly, I assumed not based on the line you had previously commented out. Here is an example of how it should work to select.

Global $items, $msg, $comb, $bot1, $bot2
GUICreate("GUI combo", 180, 110)
$items = "|item1|item2|item3"
$comb = GUICtrlCreateCombo("", 10, 10, 160)
GUICtrlSetData(-1, $items, "item3")
$bot1 = GuiCtrlCreateButton('Selecciona "item1"', 10, 40)
$bot2 = GuiCtrlCreateButton("Selecciona segundo elemento", 10, 70)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        case $GUI_EVENT_CLOSE
            ExitLoop
        case $bot1
            GUICtrlSetData($comb, "item1")
        case $bot2
            GUICtrlSendMsg($comb, $CB_SETCURSEL, 1, 0) ; Selecciona por posiciĆ³n (0 = primer elemento)
    EndSwitch
WEnd
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

×
×
  • Create New...