隐藏 TabControl 按钮以管理堆叠的面板控件
我需要处理多个面板,其中包含各种数据掩码。每个面板应使用 TreeView 控件可见。
此时,我通过使所选面板可见并将其置于顶部来手动处理面板可见性。
实际上这不太舒服,尤其是在 UI 设计器中,因为当我添加一个全新的面板时,我必须调整每个面板的大小,然后设计它......
一个好的解决方案是使用 TabControl,每个面板都包含在一个标签页。但我找不到任何方法来隐藏 TabControl 按钮,因为我已经有一个用于选择项目的 TreeView。
另一个解决方案是 ipotethic“StackPanelControl”,其中面板使用堆栈进行排列,但我在任何地方都找不到它。
处理这种 UI 的最佳解决方案是什么?
I need to handle multiple panels, containing variuous data masks. Each panel shall be visible using a TreeView control.
At this time, I handle the panels visibility manually, by making the selected one visible and bring it on top.
Actually this is not much confortable, especially in the UI designer, since when I add a brand new panel I have to resize every panel and then design it...
A good solution would be using a TabControl, and each panel is contained in a TabPage. But I cannot find any way to hide the TabControl buttons, since I already have a TreeView for selecting items.
Another solution would be an ipotethic "StackPanelControl", where the Panels are arranged using a stack, but I couldn't find it anywhere.
What's the best solution to handle this kind of UI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于上述情况,
您需要设置 TabControl 的以下属性。
For the above,
You need to set the following properties of TabControl.
您需要一点点 Win32 API 魔法。选项卡控件发送 TCM_ADJUSTRECT 消息以允许应用程序调整选项卡大小。将新类添加到您的项目中并粘贴下面所示的代码。编译。将新控件从工具箱顶部拖放到窗体上。
您将在设计时获得选项卡,以便您可以轻松地在页面之间切换。选项卡在运行时隐藏,使用 SelectedIndex 或 SelectedTab 属性在“视图”之间切换。
You need a wee bit of Win32 API magic. The tab control sends the TCM_ADJUSTRECT message to allow the app to adjust the tab size. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.
You'll get the tabs at design time so you can easily switch between pages. The tabs are hidden at runtime, use the SelectedIndex or SelectedTab property to switch between "views".