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
How do I insert a drop-down menu for a simple Windows Forms app in Visual Studio 2008?
提问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 ComboBox
with its ComboBoxStyle
(appears as DropDownStyle
in later versions) set to DropDownList
. See: http://msdn.microsoft.com/en-us/library/system.windows.forms.comboboxstyle.aspx
您可以使用 aComboBox
并将其ComboBoxStyle
(DropDownStyle
在更高版本中显示)设置为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 的框,您可以在其中继续编辑您的项目或每行填写一个项目/字符串。这应该是最简单的。