/// <summary>
/// 创建表格
/// </summary>
private void CreateTable()
{
int RowCount = 0;
// 创建表格
TableLayoutPanel table = new TableLayoutPanel();
table.Dock = DockStyle.Fill;
// 表格显示线条
table.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
// 创建表格为8列
table.ColumnCount = 8;
#region 创建第一行显示内容内容
Label labName = new Label()
{
Text = "老人姓名",
Width = 80,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleCenter
};
// 第一行第一列值
table.Controls.Add(labName, 0, RowCount);
Label labNames = new Label()
{
Text = "张天",
Width = 160,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleLeft
};
table.Controls.Add(labNames, 1, RowCount);
Label labAge = new Label()
{
Text = "年龄",
Width = 80,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleCenter
};
table.Controls.Add(labAge, 2, RowCount);
Label labAges = new Label()
{
Text = "88",
Width = 80,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleCenter
};
table.Controls.Add(labAges, 3, RowCount);
Label labSex = new Label()
{
Text = "性别",
Width = 80,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleCenter
};
table.Controls.Add(labSex, 4, RowCount);
Label labSexs = new Label()
{
Text = "男",
Width = 80,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleCenter
};
table.Controls.Add(labSexs, 5, RowCount);
Label labTypeName = new Label()
{
Text = "享受补助类别",
Width = 160,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleCenter
};
table.Controls.Add(labTypeName, 6, RowCount);
Label labTypeNames = new Label()
{
Text = "A类",
Width = 160,
Height = 30,
TextAlign = System.Drawing.ContentAlignment.MiddleCenter
};
table.Controls.Add(labTypeNames, 7, RowCount);
#endregion
#region 创建第二行
RowCount++;
Label labAddr = new Label()
{
Text = "家庭地址",
Width = 80,
Height = 30,
TextAlign = ContentAlignment.MiddleCenter
};
table.Controls.Add(labAddr, 0, RowCount);
Label labAddress = new Label()
{
Text = "湖南长沙芙蓉区",
Height = 30,
TextAlign = ContentAlignment.MiddleLeft,
Dock = DockStyle.Fill
};
table.Controls.Add(labAddress, 1, RowCount);
table.SetColumnSpan(labAddress, 7);
#endregion
#region 创建第三行
RowCount++;
Label labItemName = new Label()
{
Text = "服务项目",
Height = 30,
Width = 80,
TextAlign = ContentAlignment.MiddleCenter
};
table.Controls.Add(labItemName, 0, RowCount);
Label labServiceDetail = new Label()
{
Text = "服务明细",
Height = 30,
Width = 160,
TextAlign = ContentAlignment.MiddleCenter
};
table.Controls.Add(labServiceDetail, 1, RowCount);
Label labServiceDate = new Label()
{
Text = "服务时间",
Height = 30,
Width = 160,
TextAlign = ContentAlignment.MiddleCenter
};
table.Controls.Add(labServiceDate, 2, RowCount);
table.SetColumnSpan(labServiceDate, 2);
Label labServeMoney = new Label()
{
Text = "服务金额",
Height = 30,
Width = 160,
TextAlign = ContentAlignment.MiddleCenter
};
table.Controls.Add(labServeMoney, 3, RowCount);
table.SetColumnSpan(labServeMoney, 2);
Label labEmpName = new Label()
{
Text = "服务员工",
Width = 160,
Height = 30,
TextAlign = ContentAlignment.MiddleCenter
};
table.Controls.Add(labEmpName, 4, RowCount);
Label labDetail = new Label()
{
Text = "备注",
Width = 160,
Height = 30,
TextAlign = ContentAlignment.MiddleCenter
};
table.Controls.Add(labDetail, 5, RowCount);
#endregion
RowCount += 2;
table.RowCount = RowCount;
this.tableLayoutPanel1.Controls.Add(table, 0, 2);
}