在我的表單中,我使用了tabcontrol。我想要隱藏標籤標題和邊框兩者。我可以做任何一個,如果我試圖隱藏標題,然後邊框變得可見。任何人都可以幫助我嗎?由於這裏是我的代碼:c#:如何刪除tabcontrol邊框?
public Form3()
{
InitializeComponent();
this.NativeTabControl1 = new NativeTabControl();
this.NativeTabControl1.AssignHandle(this.tabControl1.Handle);
}
private NativeTabControl NativeTabControl1;
private class NativeTabControl : NativeWindow
{
protected override void WndProc(ref Message m)
{
if ((m.Msg == TCM_ADJUSTRECT))
{
RECT rc = (RECT)m.GetLParam(typeof(RECT));
//Adjust these values to suit, dependant upon Appearance
rc.Left -= 3;
rc.Right += 3;
rc.Top -= 3;
rc.Bottom += 3;
Marshal.StructureToPtr(rc, m.LParam, true);
}
base.WndProc(ref m);
}
private const Int32 TCM_FIRST = 0x1300;
private const Int32 TCM_ADJUSTRECT = (TCM_FIRST + 40);
private struct RECT
{
public Int32 Left;
public Int32 Top;
public Int32 Right;
public Int32 Bottom;
}
private void Form3_Load(object sender, EventArgs e)
{
//hides tabcontrol headers
tabControl1.Appearance = TabAppearance.Buttons;
tabControl1.ItemSize = new Size(0, 1);
tabControl1.SizeMode = TabSizeMode.Fixed;
}
}
對不起,它不起作用 – feather
當我嘗試應用在執行第一行代碼後在TabControl上出現以下錯誤。 ('System.Windows.Forms.TabControl'不包含'BorderBrush'的定義) –