组合或下拉框,用户还可以输入自己的值? [英] Combo or drop-down box where user can enter own value as well?

查看:154
本文介绍了组合或下拉框,用户还可以输入自己的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以使用组合或下拉框,用户可以从列表中选择给定的替代方案,还是输入自己的值?

解决方案是的,这是标准的 ComboBox 控件的功能。其精确行为取决于您为控件的样式属性设置的值。以下是快速的选项:




  • vbComboDropDown 默认样式。组合框看起来像一个单行文本框,带有一个下拉箭头。用户可以在文本框中输入任意文本,也可以从下拉列表中选择一个预定义的选项。


  • vbComboSimple 可以获得旧的经典风格的组合框。这只是一个文本框,融合在列表框的顶部(这就是组合框控件的名字!)。与默认样式一样,用户可以在顶部的文本框中输入任意文本,也可以从下方的列表框中选择一个预定义的选项。



    这种风格和默认风格之间唯一真正的区别是,所有可用选项始终在屏幕上可见。它占用了更多的屏幕空间,但它使用户更容易看出他们的选择。


  • vbComboDropDownList 将产生一个看起来非常像第一个(默认)样式的组合框,除了用户将可以在文本框中输入任意文本。他们只能选择下拉列表中可用的预定义选项之一。




作为我尽力描述的补充,您还可以看到 Microsoft的Win32组合框控件的文档,带有截图。 VB 6控件只是标准Win32控件的一个包装,所以你看到的所有东西对于VB 6应用程序都是一样的。唯一的区别是样式的名称,而不是设置一个 CBS _ * 标志,您可以使用 vb * 常量。





在这种情况下,您希望第一个选项 vbComboDropDown


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?

解决方案

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.

这篇关于组合或下拉框,用户还可以输入自己的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆