简体   繁体   English

使组合框像下拉列表(C#)

[英]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.

相关问题 如何使用 C# 从字符串数组制作类似枚举的 Unity 检查器下拉菜单? - How to make an enum-like Unity inspector drop-down menu from a string array with C#? 如何使 C# 中的 Combobox 像按钮一样工作 - How to make A Combobox in C# act like a button 在C#中更改组合框下拉列表边框颜色 - Change combobox drop down list border color in C# 如何在下拉列表中显示同一个表中的 2 个字段 MVC C# - How to display 2 fields from the same table in the drop-down list MVC C# 使用下拉列表(WCF)C#检索相应的外键 - Retrieve corresponding foreign key with drop-down list (WCF) C# 如何使用 C# 通过 Selenium WebDriver 获取下拉列表中的所有选项? - How to get all options in a drop-down list by Selenium WebDriver using C#? C# Asp.net Cascading 下拉选择列表使用 Searchable Options List 插件 - C# Asp.net Cascading drop-down select lists using Searchable Options List plugin 如何使用C#Razor生成用于下拉列表和数据选择的动态表单字段 - How to generate Dynamic Form Fields for Drop-down List and Data Selection with C# Razor C#窗体Combobox下拉列表,并建议在组合框中编写的文本上出现的列表 - C# window form Combobox drop down and sugguest appened list on text written in combobox 验证2下拉列表 - Validate 2 Drop-Down List
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM