Jump to content

Putting more than one item in combo box


Abo-Mota
 Share

Recommended Posts

  • Moderators

@Abo-Mota as is always the case, there are multiple ways to skin the proverbial cat with AutoIt. If you have a large amount of text you want to add to the combobox, in addition to AutoBert's suggestion you can also add an array, like so:

#include <Array.au3>
#include <GUIConstantsEx.au3>

Local $hGUI = GuiCreate("Test", 300, 400)
Local $hCombo = GUICtrlCreateCombo("", 10, 10, 100, 40)
Local $aArray[7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
GUICtrlSetData($hCombo, _ArrayToString($aArray, "|"))

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

4 hours ago, AutoBert said:

Use the separator (standard = '|') to add more than one item in combo box.

 

; Add additional items to the combobox.
    GUICtrlSetData($idComboBox, "Item 2|Item 3", "Item 2")

Just test the example script in help for GUICtrlCreateCombo.

Thx. it works! 

Regards, 

Abo-Mota 

😉, My FaceBook

, 🌺 صلي ع النبي و تبسم 🌺

Link to comment
Share on other sites

18 hours ago, JLogan3o13 said:

@Abo-Mota as is always the case, there are multiple ways to skin the proverbial cat with AutoIt. If you have a large amount of text you want to add to the combobox, in addition to AutoBert's suggestion you can also add an array, like so:

#include <Array.au3>
#include <GUIConstantsEx.au3>

Local $hGUI = GuiCreate("Test", 300, 400)
Local $hCombo = GUICtrlCreateCombo("", 10, 10, 100, 40)
Local $aArray[7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
GUICtrlSetData($hCombo, _ArrayToString($aArray, "|"))

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

 

 Thanks 👍

Regards, 

Abo-Mota 

😉, My FaceBook

, 🌺 صلي ع النبي و تبسم 🌺

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