隐藏TabControl的按钮来管理堆叠Panel控件 [英] Hide TabControl buttons to manage stacked Panel controls

查看:487
本文介绍了隐藏TabControl的按钮来管理堆叠Panel控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要处理多个面板,包含variuous数据口罩。每个小组必须使用一个TreeView控件是可见的。

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.

其实这是没有太大的舒适,尤其是在UI设计师,因为当我添加一个全新的面板我不得不调整每一个面板,然后设计它...

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...

一个很好的解决方案将使用一个TabControl,并且每个面板包含在TabPage的。但是,我找不到任何办法隐藏TabControl的按钮,因为我已经有选择项目一个TreeView。

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.

另一个解决方案是一个ipotethicStackPanelControl,其中面板使用的是栈安排,但我不能在任何地方找到它。

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?

推荐答案

您需要的Win32 API的神奇一丁点。标签控件发送TCM_ADJUSTRECT消息,让应用程式来调整标签的大小。添加一个新类到您的项目并粘贴如下所示的code。编译。从工具箱的上方新的控制到您的表单。

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.

您会得到在设计时的标签,所以你可以很容易地在页面之间切换。这些选项卡在运行时隐藏,使用selectedIndex或SelectedTab属性为意见之间切换。

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".

using System;
using System.Windows.Forms;

class StackPanel : TabControl {
  protected override void WndProc(ref Message m) {
    // Hide tabs by trapping the TCM_ADJUSTRECT message
    if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
    else base.WndProc(ref m);
  }
}

这篇关于隐藏TabControl的按钮来管理堆叠Panel控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆