如何在 VB.NET WinForms 中滚动 StatusStrip 控件?

发布于 2024-12-21 21:13:58 字数 111 浏览 5 评论 0原文

当 StatusStrip 的控件超出表单查看区域时,有什么方法可以在 StatusStrip 中滚动吗?我的 StatusStrip 充当带有许多标签(充当按钮)的任务栏,如果标签太多,可能会超出屏幕范围。

Is there any way to scroll in a StatusStrip when its controls exceed form viewing area? My StatusStrip acts as a taskbar with a lot of labels (acting as buttons) which if there are too many might go outside the bounds of the screen.

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

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

发布评论

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

评论(1

锦上情书 2024-12-28 21:13:58

从未在我使用过的任何Windows应用程序中见过滚动状态栏控件。

你可能认为这是一个无关紧要的观点,但我提到它是有原因的。设计符合平台惯例以及用户期望的应用程序具有巨大的优势。这些应用程序更容易编写(违反规则总是比遵守规则更难)并且更容易让用户理解和使用。

即使有滚动条,用户也很可能永远找不到它并使用它,因为他们不希望在状态栏控件上找到滚动条。我当然不会。我会在那里寻找我希望找到的信息,但找不到它,然后感到沮丧。像大多数用户一样,我不会费心阅读文档来了解我必须滚动那些永远无法滚动的内容。我只是得出结论,你的应用程序的用户界面很糟糕,然后就结束它了。

事实上,尽管你和我作为程序员可能会想到典型的[愚蠢]用户,但我作为典型的愚蠢用户是非常正确的!您的应用程序确实有一个糟糕的用户界面,因为它不标准且难以使用。这是很多程序员不理解或不欣赏的事情,但它非常重要。

因此,我强烈建议您重新考虑应用程序的 UI 设计。主要焦点(以及一般的良好设计)应该是确保重要信息在多个位置显示或访问,而不仅仅是在状态栏中。另一种选择是在状态栏中显示更少的信息。与 Windows 资源管理器非常相似,当可用屏幕空间缩小时,您应该自动隐藏不太重要的信息,并在有必要的空间时显示更多信息。将资源管理器窗口设置得非常小,您只能在状态栏中看到最基本的内容。

但是,如果您决定忽略所有这些建议并搞砸了您已经决定的内容,请继续阅读...StatusStrip 控件继承自 ScrollableControl,这意味着它具有 AutoScroll 和 HScroll 等属性。但 文档 表明此类属性是:

基础设施。该属性与此类无关。

这意味着 StatusStrip 控件不支持它们。您也许可以继承 StatusStrip 并编写自己的滚动代码,但这对我来说听起来像是很多工作。

更简单的解决方案可能是将 Panel 控件停靠在表单底部,然后在该 Panel 内部放置一个 StatusStrip 控件。确保设置容器 Panel 控件的 AutoScroll 属性,并且它应该自动展开(带有滚动条)以显示整个 StatusStrip 控件。

I have never seen a scrolling status bar control in any Windows application I've ever used.

You might think that's quite an irrelevant point, but I mention it for a reason. There's a huge advantage in designing applications that are consistent with your platform's conventions, and therefore your user's expectations. Those applications are much easier to write (breaking the rules is always harder than following them) and much easier for users to understand and use.

It's very likely that, even if there is a scrollbar, users will never find it and use it because they aren't expecting to find a scrollbar on a status bar control. I certainly wouldn't be. I'd look down there for the information I'd expect to find, not find it, and get frustrated. Like most users, I wouldn't bother reading the documentation to understand that I have to scroll something that is never scrollable. I'd just conclude your app has a bad UI and be done with it.

And in fact, despite what you and I as programmers might think of the typical [dumb] user, I as the typical dumb user would be quite correct! Your application does have a bad UI because it's non-standard and difficult to use. This is something that lots of programmers don't understand or appreciate, but it's extremely important.

Therefore, I highly recommend that you re-consider your application's UI design. The primary focus (and just general good design) should be on ensuring that vital information is displayed or accessible multiple places, not just in the status bar. Another option is to display less of that information in the status bar. Much like Windows Explorer, you should automatically hide the less important information when your available screen real estate shrinks, and display more of it when you have the necessary room to do so. Make an explorer window really small and you'll only see the bare essentials down in the status bar.

But if you decide to ignore all of this advice and bungle through what you've already decided upon, keep reading... The StatusStrip control inherits from ScrollableControl, which means that it has such properties as AutoScroll and HScroll. But the documentation indicates that such properties are:

Infrastructure. This property is not relevant for this class.

That means they're not supported on the StatusStrip control. You might be able to inherit from StatusStrip and write your own scrolling code, but that sounds like a lot of work to me.

The simpler solution is probably to dock a Panel control at the bottom of your form, and then place a StatusStrip control inside of that Panel. Make sure that you set the AutoScroll property of the container Panel control, and it should automatically expand (with scrollbars) to display the entire StatusStrip control.

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