Anna
Anna

Reputation: 23

Borderless TabControl

I have a TabControl placed on Form. which is a VB.net windows application.

I want to set tabcontrol border totally invisible similar to the formBorderstyle = none

I am unable to find any settings for the tabControl to remove the visible border. Please Suggest!

Upvotes: 1

Views: 2407

Answers (1)

Ben.Vineyard
Ben.Vineyard

Reputation: 1169

This should work and assumes there are 2 tab controls. Adjust accordingly if you have more.

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

Upvotes: 1

Related Questions