C# 中的选项卡式用户界面

发布于 2024-07-23 06:53:15 字数 155 浏览 10 评论 0原文

我想创建一个简单的选项卡式界面应用程序。 我之前在 WPF 中使用每个选项卡内的用户控件进行了此操作,并且我与主要表单进行通信以搜索父元素(表单或选项卡控件),

我如何在 WinForms 中进行相同的操作? 我需要在每个选项卡中放置哪些元素?

谢谢。

I want to create a simple tabbed interface app. I did it before in WPF using an usercontrol inside of each tab, and I comunicate with the principal form searching for a parent element (the form, or the tab control)

How could I made the same in WinForms? Which element need I put inside of each tab?

Thanks.

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

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

发布评论

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

评论(2

阳光①夏 2024-07-30 06:53:15

您可以在 winforms 应用程序中使用几乎相同的方法。 您可以将用户控件添加到 TabControl< 的选项卡页/a> 在表单上。 在用户控制代码中,您可以使用 FindForm< /a> 方法来获取父窗体。

但是,我建议您改为使用事件来与控件“向外”进行通信,以便减少它们对周围环境的依赖。

You can use pretty much the same approach in a winforms application. You can add user controls to the tab pages of a TabControl on a form. Inside the user control code you can use the FindForm method to get hold of the parent form.

However, I would suggest that you instead use events to communicate "out" from the controls, in order to make them less dependent on their surroundings.

夏雨凉 2024-07-30 06:53:15

TabPage 和 TabControl 可能是您想要研究的类和组件。 使用 Parent 属性,您可以访问所属表单,从而在需要时与其进行通信或在选项卡之间进行通信。

不过,正如 Fredrik Mörk 所建议的那样,使用事件是一种更好的做法。 =)

TabPage and TabControl might be classes and components you would want to look into. Using the Parent property you can access the owning form and thus communicate with it or between tabs, should you need it.

Though, as Fredrik Mörk suggests, using events is a far better practice. =)

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