Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a TabControl to use the full width of its parent?

The standard System.Windows.Forms.TabControl component draws a border around the TabPages it contains. If you set its Dock to Fill, these borders run up to the edge of the parent control, but they're still there, taking up screen space.

In Visual Studio, if you dock two windows in the same place, you get a TabControl-like set of tabs along the bottom, but no borders along the sides.

Is it possible to get a TabControl to display its TabPages in this manner, with no wasted screen space at the sides? If possible, I'd like to avoid solutions that involve painting the control myself.

like image 966
Simon Avatar asked Jan 29 '09 09:01

Simon


1 Answers

  1. Remove the height and width attributes from TabControl
  2. Set horizontal and vertical alignment to stretch

e.g. won't stretch;

<TabControl Height="373" Width="609" HorizontalAlignment="Stretch" Name="tabControl1" VerticalAlignment="Stretch"  VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">

e.g. will stretch;

<TabControl HorizontalAlignment="Stretch" Name="tabControl1" VerticalAlignment="Stretch"  VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
like image 168
Daniel de Zwaan Avatar answered Sep 19 '22 23:09

Daniel de Zwaan