如Delphi之TPageControl控件,其TTabSheet有TabVisible属性,在制作类似Wizard页面切换时,甚为有用。

而c#对应之TabControl控件,其页面TabPage无此属性,实现Tab标题栏隐藏,方法诸多,却不够易用,不甚方便。

stackoverflow上找到另一方法,其移自微软社区,即扩展TabControl控件接管绘制消息,相比来说 ,易用多点。

贴代码如下:

using System;
using System.Windows.Forms; public class TablessControl : TabControl
{
protected override void WndProc(ref Message m)
{
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328 && !DesignMode)
m.Result = (IntPtr);
else
base.WndProc(ref m);
} protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.Tab) || keyData == (Keys.Control | Keys.Shift | Keys.Tab) || keyData == (Keys.Left) || keyData == (Keys.Right))
return true; return base.ProcessCmdKey(ref msg, keyData);
}
}

另一种实现方式,发布TabsVisible属性:

using System;
using System.ComponentModel;
using System.Windows.Forms; public class WizardPages : TabControl {
private bool tabsVisible; [DefaultValue(false)]
public bool TabsVisible {
get { return tabsVisible; }
set {
if (tabsVisible == value) return;
tabsVisible = value;
RecreateHandle();
}
} protected override void WndProc(ref Message m) {
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328) {
if (!tabsVisible && !DesignMode) {
m.Result = (IntPtr);
return;
}
}
base.WndProc(ref m);
} protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.Tab) || keyData == (Keys.Control | Keys.Shift | Keys.Tab) || keyData == (Keys.Left) || keyData == (Keys.Right))
return true; return base.ProcessCmdKey(ref msg, keyData);
}
}

设计期间,与正常TabControl一样:

运行期效果如下:

参考资料:

Tabs in Winform

Hide Tab Header on C# TabControl

c#: TabControl隐藏选项卡(WizardPages)的更多相关文章

  1. VB中的SSTab控件隐藏选项卡方法

    请教下,VB中Sstab控件,如何隐藏选项卡呢? SSTab1.TabVisible(1) = False object.TabVisible(tab) [ = boolean ] tab 数值表达式 ...

  2. WPF TabControl 隐藏标头

    1. 将每个 TabItem 的 Visibility 属性设置为 Visibility.Collapsed 即可隐藏标头 <TabItem Visibility="Collapsed ...

  3. C#控件TabControl隐藏page

    隐藏 这个需求其实就是TABCONTROL控件会有很多提前制作好的PAGE页面,每次软件启动不可能所有页面都显示出来,目前想了个比较简单的方法解决这个问题 首先定义一个List集合存储TABCONTR ...

  4. C# TabControl 隐藏标签头(TabControl Hide Head)

    TabControl控件,有时候需要动态显示一个或者多个标签页,如果只是显示一个标签页的时候不想显示标签头,所以有可能隐藏头部的需求. 如下代码可以实现 public Form1() { Initia ...

  5. TabControl关闭选项卡

    关闭TabControl选项卡: Private Sub TabControl_Main_CloseButtonClick(sender As Object, e As EventArgs) Hand ...

  6. 【WPF】TabControl禁用部分选项卡

    需求:使用TabControl分页栏控件时,由于部分分页下的内容尚未开发完成,不希望用户能够点击切换到那些分页. 百度搜到的一些做法比较麻烦,或者说是直接把分页移除的,这些都不符合需求.需求要的是能看 ...

  7. tabcontrol动态生成选项卡,并且在选项卡中添加窗体

    http://blog.csdn.net/zx13525079024/article/details/6084733 今天在论坛上看到有人问到,如果在点击TRVEVIEW时动态生成tabcontrol ...

  8. KRBTabControl(中文)Windows选项卡控件

    本文阐述了如何在C#使自定义Windows选项卡控件. Download demo project - 82.4 KB Download source - 252 KB 介绍 本文讨论如何使用.NET ...

  9. js 的小效果---->选项卡

    js选项卡   <!doctype html> <html> <head> <meta charset="utf-8"> <t ...

随机推荐

  1. 【平台兼容性】jeecg3.7 兼容weblogic 部署改造方案

    MyEclipse 配置 WebLogic 10.3.3请参考: https://my.oschina.net/aini3884/blog/895689 常见问题: 1. problem: cvc-e ...

  2. Jsoup解析网页源码时常用的Element(s)类

    Jsoup解析网页源码时常用的Element(s)类 一.简介 该类是Node的直接子类,同样实现了可克隆接口.类声明:public class Element extends Node 它表示由一个 ...

  3. Turn the Rectangles 1008B

    output standard output There are nn rectangles in a row. You can either turn each rectangle by 9090  ...

  4. Haskell语言学习笔记(72)Free Monad

    安装 free 包 $ cabal install free Installed free-5.0.2 Free Monad data Free f a = Pure a | Free (f (Fre ...

  5. idea2017授权

    http://blog.csdn.net/qq_27686779/article/details/78870816 文章中注册码: BIG3CLIK6F-eyJsaWNlbnNlSWQiOiJCSUc ...

  6. pycharm 配置服务器,脚本,测试文件

    配置django服务器 我们配置在用pycharm开发的时候,一般都是习惯于python manage.py runserver 0.0.0.0:80000 这种方式,但是,该方式并不能进入debug ...

  7. C# 图像处理:Bitmap 与 Image 之间的转换

    Image img = this.pictureBox1.Image; Bitmap map = new Bitmap(img); Image img = Bitmap; Image和Bitmap类概 ...

  8. 阿里云栖大会 所有ppt

    https://github.com/Alimei/hangzhouYunQi2017ppt

  9. ASP.NET 三级联动

    三级联动就是用三个下拉列表框DropDownList,每个里面添加相应的东西,在第一个列表框中选择一个值,第二三个列表框都会根据第一个选择进行相应的变化,在第二个列表框中选择一个值,第三个列表框也会根 ...

  10. vue路由传参

    console.log( _this.$route.params.id)接收参数 <div class="baoming"><router-link :to=&q ...