DataGrid表头跨行合并的实现

   Private   Sub DataGrid_ItemCreated(ByVal sender As ObjectByVal 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

效果图
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值