[英]Make combobox act like drop-down list (C#)
I'm using visual studio 2010 which supports .Net 4 and doesn't have support for a Drop Down List. 我使用的Visual Studio 2010支持.Net 4,但不支持下拉列表。 I am trying to get the same effect through a combobox by disabling the ability for a user to enter free-form text, but not sure how.
我试图通过禁用用户输入自由格式文本的功能来通过组合框获得相同的效果,但不确定如何操作。 How can I accomplish this goal?
我怎样才能实现这个目标?
ADDITIONAL INFO 附加信息
Visual Studio 2010 does have support for Drop Down Lists when using .Net 4. It is actually part of the same control you're already using (the Combo Box), you just have to set the property for it. 使用.Net 4时,Visual Studio 2010确实支持下拉列表。它实际上是您已经在使用的同一控件(组合框)的一部分,您只需为其设置属性即可。
Change the DropDownStyle property to DropDownList . 将DropDownStyle属性更改为DropDownList 。
Or do it programmatically with: 或通过编程方式使用:
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
Check out the MSDN on ComboBoxes: ComboBox.DropDownStyle Property 在ComboBoxes上检查MSDN: ComboBox.DropDownStyle属性
If I understand what you mean, you want to add this code to your .cs file 如果我明白您的意思,则想将此代码添加到.cs文件中
I want you to type it out, cause it's good practice. 我希望您键入它,因为这是一种很好的做法。 If this isn't what you mean...well than you need to explain your question better.
如果这不是您的意思,那么……您将需要更好地解释您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.