在TableLayoutPanel中,如果Dock = Fill且AutoSize = true,则最后一列/行占用所有剩余空间。 [英] In TableLayoutPanel if Dock = Fill and AutoSize = true then last column/row occupy all remaining space.
本文介绍了在TableLayoutPanel中,如果Dock = Fill且AutoSize = true,则最后一列/行占用所有剩余空间。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如果我们设置AutoSize = true并且Dock = fill
,那么在TableLayoutPanel中,最后一列/行将占用所有剩余空间。
如何将其设置为所需的高度(行)和宽度(列)?
解决方案
我发现它.....
将tablelayoutpanel添加为tbl1,包含两行和两列。
设置其dock = fill autoscroll = true
并设置第一行自动调整大小和第二行absoluto 0.00 F的宽度
与第1列和第2列相同。
现在在第1行第1列添加实际的tablelayoytpanel。
优秀:-)
以上解决方案有效...
我的其余代码...
添加行并设置rowstyle ...
CustomButton是一组按钮中的按钮控件...
foreach (CustomButton b in 但是ns)
{
b.Dock = DockStyle.Top;
AddRow(b);
}
}
私有 void AddRow( CustomButton b)
{
int rowIndex = AddTableRow();
tableLayoutPanel.Controls.Add(b, 0 ,rowIndex);
}
private int AddTableRow()
{
int index = tableLayoutPanel.RowCount ++;
RowStyle style = new RowStyle(SizeType.AutoSize);
tableLayoutPanel.RowStyles.Add(style);
return index;
}
在我的情况下,
我更改了autoscroll选项删除后一行
喜欢这个,
tb1.RowCount = tb1.RowCount - 1
tb1。 RowStyles.RemoveAt(tb1.RowStyles.Count - 1)
tb1.AutoScroll = False
tb1.AutoScroll = True
然后它可以工作。
Hi all,
In TableLayoutPanel if we set AutoSize = true and Dock = fill
then last column/row will occupy all remaining space.
How to set it to required height (row) and width (column)?
解决方案
I found it.....
add tablelayoutpanel as tbl1 with two row and two column.
set its dock = fill autoscroll = true
and set width for 1st row autosize and for second absoluto 0.00 F
same for column 1 and 2.
now add actual tablelayoytpanel in 1st rows 1st column.
Excellent :-)
Solution above works...
Rest of my code...
Adding a row and setting rowstyle...
CustomButton is a buttoncontrol in a collection of buttons...
foreach (CustomButton b in buttons) { b.Dock = DockStyle.Top; AddRow(b); } } private void AddRow(CustomButton b) { int rowIndex = AddTableRow(); tableLayoutPanel.Controls.Add(b, 0, rowIndex); } private int AddTableRow() { int index = tableLayoutPanel.RowCount++; RowStyle style = new RowStyle(SizeType.AutoSize); tableLayoutPanel.RowStyles.Add(style); return index; }
In my case,
I changed autoscroll option After I removed one row
like this,
tb1.RowCount = tb1.RowCount - 1 tb1.RowStyles.RemoveAt(tb1.RowStyles.Count - 1) tb1.AutoScroll = False tb1.AutoScroll = True
and then it works.
这篇关于在TableLayoutPanel中,如果Dock = Fill且AutoSize = true,则最后一列/行占用所有剩余空间。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文