无边框TabControl

时间:2011-08-23 21:45:41

标签: .net vb.net winforms tabcontrol

我在Form上放置了一个TabControl。这是一个VB.net Windows应用程序。

我想设置tabcontrol边框完全不可见,类似于formBorderstyle = none

我无法找到tabControl的任何设置以删除可见边框。 请建议!

1 个答案:

答案 0 :(得分:1)

这应该有效,并假设有2个制表符控件。如果您有更多,请相应调整。

Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Public Class Form1

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.
Me.NativeTabControl1 = New NativeTabControl
Me.NativeTabControl2 = New NativeTabControl
Me.NativeTabControl1.AssignHandle(Me.TabControl1.Handle)
Me.NativeTabControl2.AssignHandle(Me.TabControl2.Handle)
End Sub

Private NativeTabControl1, NativeTabControl2 As NativeTabControl

Private Class NativeTabControl
Inherits NativeWindow

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 += 3
rc.Top -= 3
rc.Bottom += 3
Marshal.StructureToPtr(rc, m.LParam, True)
End If
MyBase.WndProc(m)
End Sub

Private Const TCM_FIRST As Int32 = &H1300
Private Const TCM_ADJUSTRECT As Int32 = (TCM_FIRST + 40)
Private Structure RECT
Public Left, Top, Right, Bottom As Int32
End Structure

End Class

End Class