如何使Tab页面的宽度适合TabControl的宽度 [英] How to make Tab pages' widths fit into the TabControl's width
本文介绍了如何使Tab页面的宽度适合TabControl的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有两个标签页的TabControl.
I have a TabControl with two tab pages.
如何使标签页适合TabControl的宽度,如下面的屏幕截图所示.
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;
推荐答案
首先,设置您的tabControl1大小模式:
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);
注意:1.值0表示高度为默认值. 2.将选项卡页添加到选项卡控件后,重新计算项目大小.考虑一下调整控件大小时会发生什么.
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.
这篇关于如何使Tab页面的宽度适合TabControl的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文