熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

.NET 解決TabControl 頁裡面多余邊距問題經驗分享

2013-11-13 10:36:18  來源: .NET編程 

  以下是解決方法 
直接新建一個類繼承TabControl然後 override DisplayRectangle 方法 
復制代碼代碼如下:
/// <summary> 
/// 解決系統TabControl多余邊距問題 
/// </summary> 
public class FullTabControl : TabControl { 

public override Rectangle DisplayRectangle { 
get { 
Rectangle rect = baseDisplayRectangle; 
return new Rectangle(rectLeft rectTop rectWidth + rectHeight + ); 



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


參見以下網址(VBNET)代碼 

 

C# 代碼為 

復制代碼代碼如下:
public class FullTabControl : NativeWindow { 
static int TCM_FIRST = x
static int TCM_ADJUSTRECT = (TCM_FIRST + ); 
struct RECT{ 
public int Left Top Right Bottom; 


protected override void WndProc(ref Message m) { 
if (mMsg == TCM_ADJUSTRECT) { 
RECT rc = (RECT)mGetLParam(typeof(RECT)); 
rcLeft =
rcRight +=
rcTop =
rcBottom +=
MarshalStructureToPtr(rc mLParam true); 


baseWndProc(ref m); 



調用方法new FullTabControl()AssignHandle(tabControlHandle);// tabControl為窗口上TabControl控件的名稱 

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


From:http://tw.wingwit.com/Article/program/net/201311/14096.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.