Change font of a tab control

  • Thread starter Marco Trapanese
  • Start date
M

Marco Trapanese

Hi,

I have a tab control and several other controls into it.
When I change either at design-time or at run-time the font property of
the tab control, also the inner controls will be affected.

How to change the font of a container without affect controls inside?

Thanks
Marco / iw2nzm
 
H

Herfried K. Wagner [MVP]

Marco Trapanese said:
I have a tab control and several other controls into it.
When I change either at design-time or at run-time the font property of
the tab control, also the inner controls will be affected.

How to change the font of a container without affect controls inside?

Put the controls in a panel and set the panel's 'Font' property to another
'Font' object than those of the tabcontrol.
 
M

Mick Doherty

TabPage inherits from Panel so no need to add a Panel. Just change the
TabPages Font property.

At runtime loop through the tabpages and set their Font to
Control.DefaultFont.

\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
For Each page As TabPage In Me.TabControl1.TabPages
page.Font = Control.DefaultFont
Next
End Sub
///

Alternatively, create an Inherited TabControl which sets the TabPages
default font.

\\\
Public Class myTabControl
Inherits TabControl

Protected Overrides Sub OnControlAdded(ByVal e As _
System.Windows.Forms.ControlEventArgs)
MyBase.OnControlAdded(e)
e.Control.Font = Control.DefaultFont
End Sub

End Class
///
 

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