Border TabControl

M

Martin Madreza

Hi,

i hope someone can help me.

I've got a problem with borders on a tabcontrol.

for example i bring a tabcontronl1 on a form with dockstyle = fill and
on tabpage1 i lay
another tabcontrol2 dockstyle = fill.

then there is a borders that can not be removed with the tapcontrol
settings (margin, padding),
even if i set dock = none and set the size of the inner tabcontrol
manual there is a border

does anyone knows a workaorund how to remove that borders? or does an
idea what kind
of borders that are (a keyword to search)?

(between the form and the tabcontrol1 there is also a border - if i
set borderstyle from
the form to 'none' this border is gone, maybe somewhere is a 'inner
border' setting wich
can easly overwritten - dont find the clue)

thanks for any help

martin madreza
 
M

Mick Doherty

The TabPage also has a Padding Setting which needs to be zero'd.

If you wish to remove the actual border of the TabControls then you may do
it as follows:
(expands the DisplayRectangle which the TabPage is Docked to)

assumes a form with 2 tabcontrols (TabControl1 and TabControl2).
\\\
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
///
 
B

Barry Whiteley

Hi Mick,

I have that working in VB, would you have the same code in C#?

Many thanks,

Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top