CJ7
CJ7

Reputation: 23285

Combo or drop-down box where user can enter own value as well?

Can you have a combo or drop-down box where the user can either choose from a list of given alternatives, or enter their own value?

Upvotes: 0

Views: 4199

Answers (2)

Cody Gray
Cody Gray

Reputation: 244812

Yes, this is a feature of the standard ComboBox control. Its precise behavior depends on the value you set for the control's Style property. Here's a quick run-down of the options:

  • vbComboDropDown is the default style. The combo box looks like a single-line text box with a drop-down arrow. The user can either type arbitrary text into the text box, or they can select one of the pre-defined options from the drop-down list.

  • vbComboSimple gets you the old classic-style combo box. This is literally just a text box fused on top of a list box (and that's how the combo box control got its name!). Like the default style, the user can either type arbitrary text into the text box at the top, or they can select one of the pre-defined options from the list box underneath.

    The only real difference between this style and the default style is that all of the available options are always visible on the screen. It takes up more screen real estate, but it makes it easier for the user to see exactly what their choices are.

  • vbComboDropDownList will produce a combo box that looks very much like the first (default) style, except that the user will not be able to type arbitrary text into the text box. They can only choose one of the pre-defined options available in the drop-down list.

As a supplement to my best-effort descriptions, you can also see Microsoft's documentation for the Win32 Combo Box control, complete with screenshots. The VB 6 control is just a wrapper around the standard Win32 control, so everything you see there will be the same for a VB 6 application. The only difference is the names of the styles—instead of setting one of the CBS_* flags, you use one of the vb* constants.

In this case, it sounds like you want the first option, vbComboDropDown.

Upvotes: 5

awiebe
awiebe

Reputation: 3836

That is usally called quite simply a combobox, you will have to specify what widget toolkit you are using though, in Cocoa this is an NSCombobox, in java.swing it's just a swing.combobox, in QT a Qcombobox.

Upvotes: -2

Related Questions