.NET 单选按钮“内容” 设计

发布于 2024-07-18 06:42:59 字数 473 浏览 3 评论 0原文

我正在尝试确定使用 Windows Forms .NET (C#) 让单选按钮切换面板(或另一个容器)内容的最佳方法,并保持在表单/用户控件上使用 Visual Studio 设计器的能力包含这些。

我真正喜欢的是像 TabControl 这样的东西,我可以根据选中的单选按钮以编程方式选择页面,但不显示实际的选项卡。 我不只是使用选项卡控件的原因是使用当前选定的选项卡作为输入值似乎是错误的。

显而易见的解决方案是简单地为每个单选按钮设置一个面板,并使用可见性等来切换它们 - 但这在 Visual Studio 设计器中使用很烦人,因为这些面板要么隐藏在彼此之下,要么不以正确的方式显示。位置(如果没有空间容纳超过一个应该一次显示的面板,则整体窗体的大小不正确。)

我似乎记得 Delphi 有一个 PageControl 或类似的东西,它基本上是一个选项卡控件,没有选项卡标题。

在我看来,这种情况经常出现,所以我很好奇:你会如何设置这样的事情?

I'm trying to decide the best way of having radiobuttons switch around the contents of a panel (or another container), using Windows Forms .NET (C#), and maintaining the ability to use the Visual Studio designer on the form/usercontrol that contains these.

What I'd really like is something like the TabControl where I can select the pages programmatically based on which radiobutton is checked, but without the display of the actual tabs. The reason I'm not just using a tabcontrol is that using the currently selected tab as an input-value seems wrong.

The obvious solution is to simply have a panel for each radiobutton, and switch them around using visibility and such - but this is annoying to work with in the Visual Studio designer, as these panels will either be hidden beneath each other or not in the correct position (and the overall form not in the right size if there's no room for more than the one panel that should be shown at a time.)

I seem to remember Delphi having a PageControl or something like this, which was basically a tabcontrol without the tab-header.

It seems to me that this is a situation that often arises, so I'm curious: How would you set something like this up?

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

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

发布评论

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

评论(3

等风也等你 2024-07-25 06:42:59

我总是使用可见性功能。

I always played with the visibility feature.

冰火雁神 2024-07-25 06:42:59

我想我会简单地构建这样一个页面控件。 我想不会太难(尽管设计时支持有时比您希望的要复杂一点......)

I guess I would simply build such a page control. Can't be too hard, I guess (even though design time support tend to be a tad more complicated than you would wish for sometimes...)

鸢与 2024-07-25 06:42:59

您可以将每个面板设计为用户控件。 这将为您提供设计时的灵活性。 然后,就像其他人所说的那样,在以编程方式操作它们时使用可见性。

You could design each panel as a User Control. That would give you design-time flexibility. Then, like everyone else says, use visibility when you're manipulating them programmatically.

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