如何模拟选项卡控件?
我想要有像选项卡一样的按钮 - 它们在应用程序的“页面”之间切换。我怎样才能达到这个效果?我想我可以将控件放在某种容器中并切换 visible
属性,但这合理吗?
我正在使用 WinForms。
我不想使用选项卡控件的原因是因为某些面板中已经有选项卡控件。我不想创建嵌套的选项卡地狱。我只想要某种基于按钮的漂亮的导航。
I want to have buttons that kind of act like tabs - they switch between "pages" of the application. How can I achieve this effect? I'm thinking that I could just put the controls in some kind of container and toggle the visible
attribute, but is that plausible?
I am using WinForms.
The reason I don't want to use a tab control is because some of the panels already have tab controls in them..I don't want to create a nested tab hell. I just want some kind of spiffy button based navigation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将按钮功能“附加”到面板,然后使用面板作为“选项卡”。您甚至可以创建一个用户控件,将它们本质上联系在一起。
然而,已经存在一个 TabControl(用于 Winforms)可以执行此操作。 http://msdn.microsoft.com/en- us/library/system.windows.forms.tabcontrol.aspx
如果您正在寻找适用于 ASP.Net 2.0 及更高版本的内容,您可以尝试以下操作:http://www.codeproject.com/KB/custom-controls/TabControl.aspx
You could "attach" button functionality to Panels, then use the panels as the "tabs". You could even create a UserControl that inherently ties them together.
However, a TabControl (for Winforms) already exists that does this. http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.aspx
If you're looking for something for ASP.Net 2.0 and above, you could try the following: http://www.codeproject.com/KB/custom-controls/TabControl.aspx
我认为最好的选择是使用 这个 WinForms TabStrip 控件 - 一个子类ToolStrip 的按钮被绘制为选项卡,您只需通过在选择选项卡时切换容器中显示的面板来以编程方式对待它们。
I think the best option is to use this WinForms TabStrip control -- a subclass of ToolStrip where the buttons are drawn as tabs, and you simply treat them as such programmatically by switching which panel is shown in your container as tabs are selected.