删除的TabPages /编辑TabControl的填充 [英] Remove/Edit TabControl Padding for TabPages

查看:736
本文介绍了删除的TabPages /编辑TabControl的填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用System.Windows.Forms.TabControl列出自定义页面,但似乎是3个像素上自定义的Tabcontrol的各方面硬编码填充。

I was using System.Windows.Forms.TabControl to list custom pages, but there seems be a Hardcoded Padding of 3 pixels on all sides of Tabcontrol.

我怎样才能删除。这里有一点是我不想在最前面删除标签

How I can remove that. One point here is I dont want to remove Tabs on Top

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/a8c5bc93-8f76-42e7-b501 -b12f8b5bd1eb /

我发现上面的MSDN链接whick确实消除来自四面八方,包括在其顶部我不想的TabItems利润。

I found above MSDN link whick does removes margins from all sides including TabItems on top which I dont want.

在此先感谢!

推荐答案

这是我可以修改填充的唯一途径。

This is the only way I can modify that padding.

Imports System.Runtime.InteropServices

Public Class NativeTabControl
    Inherits NativeWindow
    Private Const TCM_FIRST As Int32 = &H1300
    Private Const TCM_ADJUSTRECT As UInt32 = (TCM_FIRST + 40)
Private baseCtrl As TabControl

Public Sub New(ByVal ctrl As TabControl)
    Me.baseCtrl = ctrl
    AddHandler ctrl.HandleDestroyed, AddressOf OnHandleDestroyed
    Me.AssignHandle(ctrl.Handle)
End Sub

Private Sub OnHandleDestroyed(ByVal sender As Object, ByVal e As EventArgs)
    ' Window was destroyed, release hook.
    RemoveHandler baseCtrl.HandleDestroyed, AddressOf OnHandleDestroyed
    Me.ReleaseHandle()
End Sub

Protected Overrides Sub WndProc(ByRef m As Message)
    If (m.Msg = TCM_ADJUSTRECT) Then
        Dim rc As RECT = DirectCast(m.GetLParam(GetType(RECT)), RECT)
        'Adjust these values to suit, dependant upon Appearance
        rc.Left -= 3
        rc.Right += 1
        rc.Top -= 1
        rc.Bottom += 1
        Marshal.StructureToPtr(rc, m.LParam, True)
    End If
    MyBase.WndProc(m)
End Sub

Private Structure RECT
    Public Left, Top, Right, Bottom As Int32
End Structure
End Class

这篇关于删除的TabPages /编辑TabControl的填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆