WinForm上的TabControl而不显示Tab标头? [英] TabControl on a WinForm without showing the Tab header?
本文介绍了WinForm上的TabControl而不显示Tab标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
有没有一种方法可以在WinForm上使用TabControl而不显示Tab标题?
亲切的问候,
Jr
Hi there,
Is there a way to have the TabControl on a WinForm without showing the Tab header?
Kind regards,
Jr
推荐答案
尝试使用TabControl的派生类.它只是覆盖DisplayRectangle并为新的TabControl类添加ShowTab属性.它对您有帮助吗?
Try that derived class form TabControl. It simply overrides the DisplayRectangle and adds a ShowTab Property for your new TabControl class. Does it help you ?
<br />public class MyTabControl : TabControl<br /> {<br /> public override Rectangle DisplayRectangle<br /> {<br /> get<br /> {<br /> if (showTabs)<br /> {<br /> return base.DisplayRectangle;<br /> }<br /> else<br /> {<br /> return new Rectangle(0, 0, Width, Height);<br /> }<br /> }<br /> }<br /><br /> #region Properties<br /> private bool showTabs = true;<br /> [Category("Apparence"),<br /> Description("Indique si les onglets s''affichent."),<br /> DefaultValue(true)]<br /> public bool ShowTabs<br /> {<br /> get { return showTabs; }<br /> set<br /> {<br /> showTabs = value;<br /> RecreateHandle();<br /> }<br /> }<br /> #endregion<br /> }<br /><br />
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Marketing_Tool
{
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);
}
}
}
这篇关于WinForm上的TabControl而不显示Tab标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文