Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Tab pages' widths fit into the TabControl's width

I have a TabControl with two tab pages.

enter image description here

How can I make the tab pages fit into the width of the TabControl like shown in the below screenshot.

enter image description here

I tried with the following line of code but it does not work either.

tabControl1.SizeMode = TabSizeMode.FillToRight;
like image 316
Isuru Avatar asked Nov 09 '12 09:11

Isuru


1 Answers

First, set your tabControl1 size mode:

tabControl1.SizeMode = TabSizeMode.Fixed;

Then you have to recalculate width of the tab page header:

tabControl1.ItemSize = new Size(tabControl1.Width / tabControl1.TabCount, 0);

Pay attention: 1. value 0 means that height will be default. 2. Recalculate item size after you had added tab page to tab control. Consider what happens when you resize the control.

like image 143
Jarek Avatar answered Nov 16 '22 22:11

Jarek