[推荐]DataGrid表头跨行合并的实现

Private   Sub  DataGrid_ItemCreated( ByVal  sender  As   Object ByVal  e  As  System.Web.UI.WebControls.DataGridItemEventArgs)  Handles  DataGrid.ItemCreated
        
If  e.Item.ItemType  =  ListItemType.Header  Then
            
Dim  DataTime  As  DateTime  =   New  DateTime
            
Dim  tcl  As  TableCellCollection  =  e.Item.Cells
            tcl.Clear()
            tcl.Add(
New  TableHeaderCell)
            tcl(
0 ).RowSpan  =   2
            tcl(
0 ).Text  =   " 序号 "
            tcl.Add(
New  TableHeaderCell)
            tcl(
1 ).RowSpan  =   2
            tcl(
1 ).Text  =   " 项目名称 "
            tcl.Add(
New  TableHeaderCell)
            tcl(
2 ).RowSpan  =   2
            tcl(
2 ).Text  =   " 总投资 "
            tcl.Add(
New  TableHeaderCell)
            tcl(
3 ).RowSpan  =   2
            tcl(
3 ).Text  =   " 至上年底累计实际完成投资 "
            tcl.Add(
New  TableHeaderCell)
            tcl(
4 ).RowSpan  =   2
            tcl(
4 ).Text  =   " 当年计划完成投资 "
            tcl.Add(
New  TableHeaderCell)
            tcl(
5 ).ColumnSpan  =   4
            tcl(
5 ).Text  =  DataTime.Now.Year()  &   " 年1- "   &  DataTime.Now.Month()  &   " 月</th></tr><tr><th>完成<br>投资</th> <th>占年计<br>划(%)</th><th>资金<br>到位< /th><th>占年计<br>划(%) "
            tcl(
5 ).Attributes.Add( " BackColor " " #006699 " )
            
' tcl(5).BackColor = "#006699"
         End   If
    
End Sub
[推荐]DataGrid表头跨行合并的实现

你可能感兴趣的:(datagrid)