Windows UI 设计 - 组合框

发布于 2024-07-27 13:54:20 字数 288 浏览 1 评论 0原文

直到今天我才意识到列表框(如 HTML 表单控件下拉选择框)和“组合框”(列表框和文本输入控件的组合)之间的区别。 因此,组合框允许用户输入新值,如果进行编程,则会将该值附加到单击时显示的值列表中。

刚刚读了几本关于界面设计的书,我认为虽然这个概念听起来很酷,并且最终会让我不必制作另一个界面来“添加”选择,但我觉得这可能会让不太高级的用户感到困惑,因为他们可能会错过您可以通过这种方式输入值的事实。

有人对组合框的使用及其与良好的 UI 设计原则的优缺点有什么意见吗? 我的应用程序应该被所有年龄段的许多人使用。

Until today I had not realized there was a difference between a list-box (like the HTML Form control drop-down selection box) and a "combo box" which is a combination of the list-box and the text-entry control. So the ComboBox allows the user to enter in a new value and if programed to do so, will append the value to the list of values it displayed when clicked on.

Having just read a few books on interface design, I think that while the concept sounds cool, and will ultimately save me having to make another interface to 'add' choices, I feel like it may be confusing to less-than-advanced users who may miss the fact that you could enter values in this way.

Does anyone have any opinions on the use of the combo box and its pro/con vis-a-vis good UI design principles? My application should be used by many people of all age groups.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

回忆那么伤 2024-08-03 13:54:20

马特,这里有一些可能对您有用的细节,如果您继续的话。

我已经按照您提到的方式在表单上的几个地方使用了组合框。

除了添加功能之外,您还可以进行编辑和编辑。 向用户删除选项,用户可以在其中编辑/重命名和删除组合条目。 但是,在提供此功能时,您需要非常小心选择的索引,因为它可能会变得非常混乱。

就我而言,我有以下三项来处理上述所有功能:

  1. 带有 DropDownStyle = 的组合框
    下拉
  2. 保存按钮
  3. 删除按钮

功能如下:

在组合框中,除了用户已保存的项目之外,我还有一个项目--新建--顶部。
当用户必须编辑/重命名某个项目时,他应该从组合中选择该项目,在组合中键入新名称,然后单击“保存”。
如果用户想要添加新项目,他应该从组合中选择--New--,在组合中输入名称(这将覆盖--New--),然后单击保存
如果用户需要删除一个项目,他应该简单地选择该项目并单击删除

我已经实现了 SelectionChangeCommissed 事件而不是 SelectedIndexChanged ,因为后者会在以下情况下触发事件:所选索引是通过代码设置的,而前者仅当用户从屏幕上选择组合框中的项目时才设置。

此外,我还维护了一个名为 _selectedComboID 的表单级别变量,它存储当前所选组合项的 ID。 它在 SelectionChangeCommited 事件处理程序中设置。 这是因为,如果您必须重命名组合中的条目,您将首先选择它。 那时 selectedIndex 是正确的(您选择的索引)。 然后,由于您需要重命名它,因此您将编辑组合文本并单击“保存”。 但是,由于您已经编辑了名称,它现在与所选索引混淆了。 因此,当用户做出选择时,我事先将其保存在变量中。

在 Save 方法中,我检查了 _selectedComboID 是否与 --New-- 的 ID 相同。 如果是,则触发插入代码,否则触发编辑代码。 在这两种情况下,除了其他验证之外,您还需要检查用户选择的名称是否尚不存在。

如果您为组合框设置 Sorted = true,则在整个代码中使用 SelectedItem 而不是 SelectedValue 非常重要。 这是因为当您将组合框的排序设置为 true 时,它​​会弄乱所选值。 您可以参考我的帖子 在 a 中设置所选项目不带循环的 ListBox 了解详细信息。

哇,那太大了! 希望能帮助到你 :)

Matt, here are some details that might be of use to you, in case you proceed with it.

I have used combo boxes in a couple of places on my forms in exactly the way you have mentioned.

In addition to the adding facility, you can also give edit & delete options to the user where the user can edit/ rename and delete the combo entries. However, you need to be extremely careful with the selected index when providing this feature as it can get pretty messy.

In my case, I have the following three items to take care of all the above mentioned functionality:

  1. Combo box with DropDownStyle =
    DropDown
  2. Save button
  3. Delete button

Functionality is as follows:

In the combo box in addition to the items already saved by the user, I have an item --New-- at the top.
When the user has to edit/ rename an item, he should select the item from the combo, type the new name in the combo and then click Save.
If the user wants to add a new item, he should select --New-- from the combo, type in the name in the combo (this will overwrite --New--) and click Save
If the user needs to delete an item, he should simply select the item and click on Delete

I have implemented the SelectionChangeCommitted event rather than the SelectedIndexChanged, as the latter fires event if the selected index is set through code, whereas the former only when user is selecting an item in the combo box from the screen.

In addition, I have maintained a form level variable called _selectedComboID which stores the id of the currently selected combo item. It gets set in the SelectionChangeCommitted event handler. This is because, if you have to rename an entry in the combo, you will first select it. At that time the selectedIndex is correct (the one you have selected). Then since you need to rename it, you will edit the combo text and click Save. However, since you have edited the name, it now messes with the selected index. So I save it in a variable before hand when user makes the selection.

In the Save method, I have checked if _selectedComboID is same as the ID for --New--. If yes, the insertion code is fired, else the edit code. In both cases, you need to check that the name chosen by the user doesn't already exist, in addition to other validations.

If you are setting Sorted = true for your combo box, it is very important to use SelectedItem throughout your code rather than SelectedValue. This is because when you set sorted as true for a combo box, it messes up the selected values. You can refer to my post on Setting selected item in a ListBox without looping for details.

Wow, that was huge!!! Hope it helps :)

空城仅有旧梦在 2024-08-03 13:54:20

优点:易于添加新选项(对于用户)

缺点:易于添加新选项(尤其是稍后当您谈论数据清理、重复条目时。当您允许自由文本输入时,基本上是相同的缺陷)。

Pro: Easy to add new options (for the user)

Con: Easy to add new options (especially later when you are talking about data clean up, duplicate entries. Basically the same flaw when you allow free text entry).

浊酒尽余欢 2024-08-03 13:54:20

这个来自 kdedevelopers.org 的页面值得一读。
我看看能不能总结一下。

列表框

+ 适合显示短列表
+ 始终显示大多数选项
+ 因此,当用户可以从列表中选择多个选项时,它会非常有效
- 列表框不支持直观地“添加”到选项列表

Combobox

+ 适合长列表。 它防止大列表占用太多用户界面空间
- 仅显示一个选定的选项 - 隐藏选项,除非您单击下拉按钮。
+ 允许用户能够添加到选项列表。 通常有一个样式属性,您可以在其中进行自定义,例如在您不需要时阻止“添加”。

其他的可以随意补充。 谦虚的建议:希望通过评论。 任何人都可以将赞同的评论移至帖子文本中。

This page from kdedevelopers.org was a good read.
Let me see if I can summarize.

Listbox

+ Good for showing a short list
+ Shows most options at all times
+ It follows that it works great when the user can choose multiple options from a list
- Listboxes do not support "adding" to the list of choices intuitively

Combobox

+ Good for long lists. It prevents big lists from taking up too much space on the UI.
- Shows one selected option only - the choices are hidden unless you click on the dropdown button.
+ Allows the feature of users being able to add to the list of choices. Usually has a style property, where you can customize e.g. prevent 'addition' in case you don't want it.

Others feel free to add on. Humble suggesion: hopefully via comments. Upvoted comments can then moved into the post text by anyone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文