. NET experience in solving extra margins on the TabControl page

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.