Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# Windows Form Tab Control Resize 1

Status
Not open for further replies.

mbowles

Programmer
Aug 27, 2001
41
US
How can you set a c# tab control to resize with the parent form. The eintire contents of my app are in tab pages and when user maximises, I need it to do so as well.
Thanks
 
mbowles,
Trap the Form's Resize event and write code in the Resize event handler that will resize your tab control based on the size of the form.

Just in case you don't know how to write an event handler for the Resize event, this is how:

1 - Add a method to your form and call it Form_Resize (you may call it something else but I think Form_Resize makes a lot of sense!). The signature of this method must be as follows:
Code:
[COLOR=blue]private [b]void[/b][/color] Form_Resize([b][COLOR=blue]object[/color] sender,
                         EventArgs e[/b])
{[COLOR=green]// Resize the tab controls here[/color]}
2 - In the InitializeComponent method (the one created automatically by the designer), add the following line of code:
Code:
[COLOR=blue]this[/color].Resize += 
    [COLOR=blue]new[/color] System.EventHandler([COLOR=blue]this[/color].Form_Resize);
Then, simply write code in the Form_Resize method that will resize your tab controls based on the size of the form.

Hope this helps!

JC

Friends are angels who lift us to our feet when our wings have trouble remembering how to fly...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top