欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

.NET 解決TabControl 頁里面多余邊距問題經(jīng)驗分享

 更新時間:2012年04月04日 18:07:05   作者:  
不知道各位同學有沒有遇到在向TabPage添加內(nèi)容后,里面的東西總是填不滿 TabPage,總是有幾個像素的空白邊距
以下是解決方法:
1.直接新建一個類,繼承TabControl,然后 override DisplayRectangle 方法:
復制代碼 代碼如下:

/// <summary>
/// 解決系統(tǒng)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);
}
}
}

以后用 FullTabControl 就行。(這種方法簡單)


2.參見以下網(wǎng)址(VB.NET)代碼:

http://www.blueshop.com.tw/board/FUM20050124191756KKC/BRD201112281018075B8.html

C# 代碼為:

復制代碼 代碼如下:

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);
}
}


調用方法:new FullTabControl().AssignHandle(tabControl1.Handle);// tabControl1為窗口上TabControl控件的名稱

版權聲明作者:夏榮全
郵箱:lyout(at)163.com

相關文章

最新評論