如何处理 Winforms 中临时无用的控件(隐藏与禁用)?

发布于 2024-07-13 02:52:00 字数 289 浏览 4 评论 0原文

一个表单很常见,其中带有一个复选框,说明“使用 foo”,紧接着是一个文本框,用户可以在其中输入他想要使用的“foo 值”。 当然,只有在选中“Use foo”时此文本框才有用

我不知道处理这种情况的最佳方法:

  1. 禁用文本框(即textboxfoo.Enabled = false;)
  2. 隐藏它(即textboxfoo.Visible = false ;)
  3. 让用户输入一个 foo 值(如果他愿意的话),并忽略他输入的值。

有我可以遵循的最佳实践吗?

It's quite common to have a form with a checkbox stating "Use foo" immediately followed by a textbox where the user can input the "foo value" he want's to use. Of course, this textbox is useful only if "Use foo" is checked

I don't know the best way to deal with this situation :

  1. Disable the textbox (ie textboxfoo.Enabled=false;)
  2. Hide it (ie textboxfoo.Visible=false;)
  3. Let the user input a foo value if he wants to, and ignore the value he entered.

Is there a best practice that I can follow ?

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

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

发布评论

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

评论(7

┈┾☆殇 2024-07-20 02:52:00

应禁用文本框。

如果文本框被隐藏,那么表单的可见更改将使程序不太用户友好。 一个例子是 Microsoft Office 中旧的(非常不受欢迎的)消失的菜单项。 人们不希望屏幕上的东西移动。 这让人迷失方向。

如果允许用户输入无用的值,则会给人一种输入该值有一定效果的错误印象。

The textbox should be disabled.

If the textbox is hidden, then the visible alteration of the form will make the program less user-friendly. An example of this is the old (very unpopular) disappearing menu items that used to be in Microsoft Office. People don't want things moving around on their screens. It's disorienting.

If the user is permitted to input a useless value, then that gives the false impression that entering the value has some effect.

囚我心虐我身 2024-07-20 02:52:00

在这种情况下,禁用文本框是最佳选择。 当复选框被选中/取消选中时文本框被启用/禁用的事实为用户提供了有用的反馈:use foo 选项需要 foo 值,并且 foo 值仅在选择 use foo 选项时才有意义。

隐藏文本框不太令人满意 - 如果未选中该框,用户将不会意识到启用 foo 选项将允许他们指定 foo 值。 想象一下他们自己想:“我最好不要选择 use foo 选项,因为我不知道将使用什么 foo 值。”

第三个选项是最差的,因为它并不表示输入的值将被忽略。

Disabling the text box is the best option in this case. The fact that the text box is enabled/disabled as the checkbox is checked/unchecked provides useful feedback to the user: the use foo option expects a foo value, and the foo value is only meaningful if the use foo option is selected.

Hiding the text box is less satisfactory - if the box isn't checked, the user won't realize that enabling the foo option will allow them to specify the foo value. Imagine them thinking to themselves: "I'd better not select the use foo option, as I have no idea what foo value will be used."

The third option is the worst, since doesn't indicate that the entered value will be ignored.

如痴如狂 2024-07-20 02:52:00

禁用文本框

隐藏文本框后,用户可能会跳过选项“Use Foo”,因为他们不清楚将如何或应该如何定义“foo”。 当文本框可见但被禁用时,用户将认识到,一旦他们说想要使用“foo”,他们就可以定义它。

Disable the textbox

With the textbox hidden the user may skip over the option "Use Foo" since it won't be clear to them how they will or should define "foo". With the textbox visible but disabled the user will recognize that they can define "foo" once they say they want to use it.

东北女汉子 2024-07-20 02:52:00

明确禁用文本框是有利的,因为用户仍然可以通过视觉线索知道“Foo”将使他们能够做什么。

但是“更多选项>>”呢? / “<< 较少选项”面板在选中/取消选中“Foo”时打开或关闭? 从开发人员的角度来看,工作量太大,和/或从用户的角度来看,摆弄太多? 我自己,我喜欢它清理界面的方式,因为“Foo”(隐藏时)的默认值是合适的。

(话虽如此,我并没有在任何地方都使用它。所有美好事物都要适度。)

Clearly disabling the text box is favoured because the user still has a visual clue as to what "Foo" will enable them to do.

But about what about the "More options >>" / "<< Less options" panel that opens up or closes as "Foo" is checked/uncheck? To much work, from the developer's perspective, and/or too much fiddling, from the user's perspective? Myself, I like the way it cleans up the interface, given that the defaults for "Foo" (when hidden) are appropriate.

(Having said that, I don't use that everywhere. Moderation in all good things.)

花辞树 2024-07-20 02:52:00

我更喜欢禁用而不是隐藏,因为它可以避免对话框中出现不必要的空白。

I favour disabling over hiding, if only because it avoids unnecessary white space on your dialog.

明月夜 2024-07-20 02:52:00

禁用文本框。
它向用户明确表明有一个选项恰好不可用。
隐藏它有时会得到“我的盒子去哪儿了”的用户响应。

Disable the text box.
It makes it clear to user that there is an option that happens to be unavailable.
Hiding it will sometimes get a user response of "Where did my box go".

一影成城 2024-07-20 02:52:00

另一种选择是让输入者输入一些数据(如果他也愿意),但如果他开始在 foo 文本框中输入,则自动选中 foo 复选框。

Another option would be to let the enter input some data if he wants too, but to auto-check the foo checkbox if he starts typing into the foo textbox.

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