亲宝软件园·资讯

展开

TabControl 多余边距 .NET 解决TabControl 页里面多余边距问题经验分享

人气:0
想了解.NET 解决TabControl 页里面多余边距问题经验讲解的相关内容吗,在本文为您仔细讲解TabControl 多余边距的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:TabControl,多余边距,下面大家一起来学习吧。
以下是解决方法:
1.直接新建一个类,继承TabControl,然后 override DisplayRectangle 方法:
复制代码 代码如下:

/// <summary>
/// 解决系统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.参见以下网址(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

加载全部内容

相关教程
猜你喜欢
用户评论