Jump to content

Recommended Posts

Posted

Is it possible to disable editing in a ComboBox while still allowing selection from the dropdown list? I.E. I would like the items in the ComboBox to be static.

/Why Tea

Posted
Posted

Yes!! The editing is the default style, so to change it just set the style to: $CBS_DROPDOWNLIST (requires #include<ComboConstants.au3>), or 0x0003.

#include<ComboConstants.au3>

$hGUI = GUICreate ("Testing combo box")
GUICtrlCreateCombo ("", 2, 2, 100, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData (-1, "Item 1|Item 2|Item 3", "Item 1")
GUISetState ()
While GUIGetMsg () <> -3
WEnd

Mat

  • 9 years later...
Posted (edited)
On 22/09/2009 at 1:57 PM, Mat said:

Yes!! The editing is the default style, so to change it just set the style to: $CBS_DROPDOWNLIST (requires #include<ComboConstants.au3>), or 0x0003.

 

 

#include<ComboConstants.au3>

$hGUI = GUICreate ("Testing combo box")
GUICtrlCreateCombo ("", 2, 2, 100, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData (-1, "Item 1|Item 2|Item 3", "Item 1")
GUISetState ()
While GUIGetMsg () <> -3
WEnd

 

Mat

Hi,

I know this is an almost 10 year old thread but my question is relevant to this topic. When I use  $CBS_DROPDOWNLIST, If my combo has a lot of elements, it won't scroll through them all. it only shows the ones that fit the height value. Is there anything else I can add to this to have both scroll and entries disabled? I've looked in the GUI Control Styles but found nothing.

 

EDIT: Nevermind, found it. GUICtrlCreateCombo( "Combo", 45, 30, 400, 100, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))

Edited by Moist
Posted

Technically the most correct is to use $GUI_SS_DEFAULT_COMBO style as noted in Helpfile for GUICtrlCreateCombo().

 

So instead of

GUICtrlCreateCombo ("", 2, 2, 100, 20, $CBS_DROPDOWNLIST)

You should use

GUICtrlCreateCombo ("", 2, 2, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))

and in this case there will be also vertical scrollbar which is included in $GUI_SS_DEFAULT_COMBO (among other default styles)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...