C# 如何在 Visual Studio 2008 中为简单的 Windows 窗体应用程序插入下拉菜单?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1030998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:33:57  来源:igfitidea点击:

How do I insert a drop-down menu for a simple Windows Forms app in Visual Studio 2008?

c#visual-studiovisual-studio-2008drop-down-menu

提问by

There appears to be every other kind of drop-down menu--those that allow user input, those for integers only, those that don't...drop down, and even those that have ugly check boxes next to them. I just want a simple drop-down menu (like you'd see if I used in html) that lets the user choose exactly ONE item. (and one's chosen by default)

似乎还有其他所有类型的下拉菜单——那些允许用户输入的,那些只用于整数的,那些不......下拉的,甚至那些旁边有丑陋的复选框的。我只想要一个简单的下拉菜单(就像你在 html 中使用的那样),让用户选择一个项目。(默认选择一个)

Any ideas? This should be extremely easy, yet I've spent an hour and half figuring this out...

有任何想法吗?这应该非常简单,但我花了一个半小时才弄明白这个......

回答by Mark Seemann

You can use a ComboBoxwith its ComboBoxStyle(appears as DropDownStylein later versions) set to DropDownList. See: http://msdn.microsoft.com/en-us/library/system.windows.forms.comboboxstyle.aspx

您可以使用 aComboBox并将其ComboBoxStyleDropDownStyle在更高版本中显示)设置为DropDownList。请参阅:http: //msdn.microsoft.com/en-us/library/system.windows.forms.comboboxstyle.aspx

回答by Joe

You can use ComboBox, then point your mouse to the upper arrow facing right, it will unfold a box called ComboBox Tasks and in there you can go ahead and edit your items or fill in the items / strings one per line. This should be the easiest.

您可以使用 ComboBox,然后将鼠标指向右上方的箭头,它将展开一个名为 ComboBox Tasks 的框,您可以在其中继续编辑您的项目或每行填写一个项目/字符串。这应该是最简单的。