tableLayoutPanel控件的应用 tableLayoutPanel中那个单元格怎么设置大小啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //只能设置某行某列的高和宽吧 tableLayoutPanel1.RowStyles[rowindex].Height = 100; tableLayoutPanel1.ColumnStyles[columnindex].Width = 100; RowStyle rs = tableLayoutPanel1.RowStyles[rindex]; rs.SizeType = SizeType.Absolute; rs.Height = 100; ColumnStyle cs = tableLayoutPanel1.ColumnStyles[cindex]; cs.SizeType = SizeType.Absolute; cs.Width = 100; /// <summary> /// 设置网格大小 /// </summary> public virtual void _SetGridSize() { int width = this.tableLayoutPanel1.Width; //宽度 int height = this.tableLayoutPanel1.Height; //高度 //行数列数 int rowcount = this.tableLayoutPanel1.RowCount; int columncount = this.tableLayoutPanel1.ColumnCount; //减去网格线 宽 if (this.tableLayoutPanel1.CellBorderStyle == TableLayoutPanelCellBorderStyle.Single) //还有或者 { width -= (columncount + 1); //减去条线的宽度 height -= (rowcount + 1); } //获取余数 int rowremainder = height % rowcount; //余数 int colremainder = width % columncount; //AVG int rowheight = height / rowcount; int columnwidth = width / columncount; //设置行高 for (int i = 0; i < rowcount; i++) { RowStyle rs = tableLayoutPanel1.RowStyles[i]; rs.SizeType = SizeType.Absolute; if (i < rowremainder) { rs.Height = rowheight + 1; //把多余的数平均一下,用float类型计算会有点问题,所以干脆用int } else { rs.Height = rowheight; } } //设置列宽 for (int j = 0; j < columncount; j++) { ColumnStyle cs = tableLayoutPanel1.ColumnStyles[j]; cs.SizeType = SizeType.Absolute; if (j < colremainder) { cs.Width = columnwidth + 1; } else { cs.Width = columnwidth; } } } 求把一个网络论坛和C/S软件连接起来的思路 C#实现拦截键盘的中文输入 还有问题啊.. 在C#的代码编辑状态下,怎样得到 javascript 中 confirm 的返回值 winform中可不可以使用正则表达式? 如何在winform下嵌入简单的网页 请问大虾们:如何获得用户收藏夹及其子文件夹的存储信息呢? 为什么在装了点NET2003的环境下可用,在只装框架的系统下报错,大虾救救我! 登录成功后会指向那个页面 从金蝶K/3数据库中读取image类型转换图片时提示参数无效 有什么工具软件可以检测C#代码的执行效率? static关键字的好处?什么时候该用?
//只能设置某行某列的高和宽吧
tableLayoutPanel1.RowStyles[rowindex].Height = 100;
tableLayoutPanel1.ColumnStyles[columnindex].Width = 100;
RowStyle rs = tableLayoutPanel1.RowStyles[rindex];
rs.SizeType = SizeType.Absolute;
rs.Height = 100;
ColumnStyle cs = tableLayoutPanel1.ColumnStyles[cindex];
cs.SizeType = SizeType.Absolute;
cs.Width = 100;
/// <summary>
/// 设置网格大小
/// </summary>
public virtual void _SetGridSize()
{
int width = this.tableLayoutPanel1.Width; //宽度
int height = this.tableLayoutPanel1.Height; //高度 //行数列数
int rowcount = this.tableLayoutPanel1.RowCount;
int columncount = this.tableLayoutPanel1.ColumnCount; //减去网格线 宽
if (this.tableLayoutPanel1.CellBorderStyle == TableLayoutPanelCellBorderStyle.Single) //还有或者
{
width -= (columncount + 1); //减去条线的宽度
height -= (rowcount + 1);
}
//获取余数
int rowremainder = height % rowcount; //余数
int colremainder = width % columncount; //AVG
int rowheight = height / rowcount;
int columnwidth = width / columncount; //设置行高
for (int i = 0; i < rowcount; i++)
{
RowStyle rs = tableLayoutPanel1.RowStyles[i];
rs.SizeType = SizeType.Absolute;
if (i < rowremainder)
{
rs.Height = rowheight + 1; //把多余的数平均一下,用float类型计算会有点问题,所以干脆用int
}
else
{
rs.Height = rowheight;
}
} //设置列宽
for (int j = 0; j < columncount; j++)
{
ColumnStyle cs = tableLayoutPanel1.ColumnStyles[j];
cs.SizeType = SizeType.Absolute;
if (j < colremainder)
{
cs.Width = columnwidth + 1;
}
else
{
cs.Width = columnwidth;
}
}
}