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

时间秒杀一切 提交于 2019-12-06 01:43:21

问题


I have a TabControl with two tab pages.

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

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

tabControl1.SizeMode = TabSizeMode.FillToRight;

回答1:


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.




回答2:


Use SizeMode on the TabControl: http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.sizemode.aspx




回答3:


this is illegal way to solve this kind of issue

Increase the padding (X,Y) X 100 // represent some allowed figures Y 3 // represent some allowed figure.



来源:https://stackoverflow.com/questions/13305457/how-to-make-tab-pages-widths-fit-into-the-tabcontrols-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!