|  | 
 
| https://www.cnblogs.com/swjian/p/9815155.html winform用 tablayoutpanel
 C# TableLayoutPanel使用方法
 一、利用TableLayoutPanel类展示表格,以10行5列为例
 
 第1步:在前台创建一个panel,使TableLayoutPanel对象填充其内部。
 
 第2步:创建TableLayoutPanel类,其实例对象名为table
 
 TableLayoutPanel table = new TableLayoutPanel();
 第3步:设置列样式,循环显示行
 
 复制代码
 private void Form2_Load(object sender, EventArgs e)
 {
 // 默认添加一行数据
 table.Dock = DockStyle.Top;     //顶部填充
 panel1.Controls.Add(table);
 table.ColumnCount = 5;          //5列
 table.Height = table.RowCount * 40; //table的整体高度,每行40
 
 table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, table.Width * 0.2f));    //利用百分比计算,0.2f表示占用本行长度的20%
 table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, table.Width * 0.2f));
 table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, table.Width * 0.2f));
 table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, table.Width * 0.2f));
 table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, table.Width * 0.2f));
 
 for (int i = 1; i <= 10; i++)
 {
 AddRow("苹果"+i.ToString().PadLeft(2,'0'),"橘子" + i.ToString().PadLeft(2, '0'), "香蕉" + i.ToString().PadLeft(2, '0'), "香瓜" + i.ToString().PadLeft(2, '0'), "甘蔗" + i.ToString().PadLeft(2, '0'));
 
 | 
 |