Vertical align middle(verticalalign)
大家好,我是小十,我来为大家解答以上问题。Vertical align middle,verticalalign很多人还不知道,现在让我们一起来看看吧!
用后台代码+前台设计实现。
private void CreateHeader()
{
this.GridView1.HeaderRow.Cells.Clear();
tdheader=new TableCell();
tb=new Table();
tb.Width = 720;
tb.BorderWidth = 0;
tb.CellPadding = 0;
tb.CellSpacing = 0;
tr=new TableRow();
td = new TableCell();
td.RowSpan = 2;
td.HorizontalAlign = HorizontalAlign.Center;
td.VerticalAlign = VerticalAlign.Middle;
td.Width = 100;
td.Text = "编号";
tr.Cells.Add(td);
td = new TableCell();
td.RowSpan = 2;
td.HorizontalAlign = HorizontalAlign.Center;
td.VerticalAlign = VerticalAlign.Middle;
td.Text = "值1";
tr.Cells.Add(td);
td = new TableCell();
td.ColumnSpan = 2;
td.HorizontalAlign = HorizontalAlign.Center;
td.VerticalAlign = VerticalAlign.Middle;
td.Text = "值2";
tr.Cells.Add(td);
tb.Rows.Add(tr);
tr=new TableRow();
td = new TableCell();
td.HorizontalAlign = HorizontalAlign.Center;
td.VerticalAlign = VerticalAlign.Middle;
td.Width = 100;
td.Text = "值3";
tr.Cells.Add(td);
td = new TableCell();
td.HorizontalAlign = HorizontalAlign.Center;
td.VerticalAlign = VerticalAlign.Middle;
td.Width = 100;
td.Text = "值4";
tr.Cells.Add(td);
tb.Rows.Add(tr);
tdheader.Width = 720;
tdheader.ColumnSpan = 4;
tdheader.Controls.Add(tb);
this.GridView1.HeaderRow.Cells.Add(tdheader);
}
本文到此讲解完毕了,希望对大家有帮助。