The solution is as follows:
1. Create a new class, inherit TabControl, And Then override DisplayRectangle method:
Copy codeThe Code is as follows:
/// <Summary>
/// Solve the problem of excessive margin of system TabControl
/// </Summary>
Public class FullTabControl: TabControl {
Public override Rectangle DisplayRectangle {
Get {
Rectangle rect = base. DisplayRectangle;
Return new Rectangle (rect. Left-4, rect. Top-4, rect. Width + 8, rect. Height + 7 );
}
}
}
Use FullTabControl later. (This method is simple)
2. See the following URL (VB. NET) code:
Http://www.blueshop.com.tw/board/FUM20050124191756KKC/BRD201112281018075B8.html
C # code:
Copy codeThe Code is as follows:
Public class FullTabControl: NativeWindow {
Static int TCM_FIRST = 0x1300;
Static int TCM_ADJUSTRECT = (TCM_FIRST + 40 );
Struct RECT {
Public int Left, Top, Right, Bottom;
}
Protected override void WndProc (ref Message m ){
If (m. Msg = TCM_ADJUSTRECT ){
RECT rc = (RECT) m. GetLParam (typeof (RECT ));
Rc. Left-= 4;
Rc. Right + = 3;
Rc. Top-= 4;
Rc. Bottom + = 3;
Marshal. StructureToPtr (rc, m. LParam, true );
}
Base. WndProc (ref m );
}
}
Call method: new FullTabControl (). AssignHandle (tabControl1.Handle); // tabControl1 is the name of the TabControl Control in the window.
Copyright holder: Xia Rongquan
Email: lyout (at) 163.com