在项目中新建一个类并添加以下代码,编译项目,这样你就创建了一个自定义的TabControl。我们可以在工具箱(toolbox)的顶部拖拽刚创建的控件到窗体上。在设计时,该控件看起来和TabControl一样。但是在运行时,只能看到页面。我们可以通过SelectIndex属性来选择浏览的页面。
代码:
using System;
using System.Windows.Forms;
public class WizardPages : TabControl
{
protected override void WndProc(ref Message m)
{
// 通过捕获TCM_ADJUSTRECT信息来隐藏标签
if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
else
base.WndProc(ref m);
}
}