WPF 列表框与组合框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38527899/
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-09-13 13:53:08  来源:igfitidea点击:

WPF ListBox vs ComboBox

c#wpfmvvmdata-binding

提问by Verbal Kint

I'm working on an application with C# and WPF, in which I need to bind to a dictionary and display key-value pairs. How are ListBoxes different from ComboBoxes, and what are some possible advantages/disadvantages of using one over the other?

我正在使用 C# 和 WPF 开发一个应用程序,我需要在其中绑定到字典并显示键值对。ListBoxes 与 ComboBoxes 有什么不同,使用一个比另一个有哪些可能的优点/缺点?

回答by ViVi

A ComboBox is a combination of listbox and edit control. A simple combobox is just a listbox with an edit control at the top; you can select from the list or type. a combobox with style "dropdown" is the same, but the listbox doesn't show up until you click the dropdown glyph. You can dropdown and select or just type in the edit control. a combobox with dropdownlist style is similar, but you can only select from the list presented - you can't type in what you want in the edit control.

ComboBox 是列表框和编辑控件的组合。一个简单的组合框只是一个顶部带有编辑控件的列表框;您可以从列表中选择或键入。样式为“下拉”的组合框是相同的,但在您单击下拉字形之前,列表框不会显示。您可以下拉并选择或直接输入编辑控件。具有下拉列表样式的组合框类似,但您只能从显示的列表中进行选择 - 您不能在编辑控件中输入您想要的内容。

Basically, a combobox (non simple style) takes up a lot less screen realestate than a full-on listbox.

基本上,组合框(非简单样式)比完整的列表框占用更少的屏幕空间。

Source : https://social.msdn.microsoft.com/Forums/en-US/3b5be60d-36c5-49aa-b49e-aa8625f53b62/what-is-the-difference-between-listbox-and-combobox-control?forum=netfxcompact

来源:https: //social.msdn.microsoft.com/Forums/en-US/3b5be60d-36c5-49aa-b49e-aa8625f53b62/what-is-the-difference-between-listbox-and-combobox-control?forum= netfxcompact

List Box :

列表框 :

  1. Occupies more space but shows more than one value.

  2. We can select multiple items.

  3. we can use checkboxes with in the list box.

  1. 占用更多空间但显示多个值。

  2. 我们可以选择多个项目。

  3. 我们可以在列表框中使用复选框。

Combo Box:

组合框:

  1. Occupies less space but shows only one value for visibility

  2. Multiple select is not possible

  3. can't use checkboxes within combo boxes

  1. 占用更少的空间,但只显示一个可见度值

  2. 多选是不可能的

  3. 不能在组合框中使用复选框

Also have a look at http://devproconnections.com/aspnet/dropdownlist-listbox-and-combobox-whats-difference

也看看http://devproconnections.com/aspnet/dropdownlist-listbox-and-combobox-whats-difference