争怎路由网/网站教程/内容

DataGrid多层表头设计

网站教程2024-07-03 阅读
  <asp:datagrid id="UserDg" OnItemCreated="DataGrid1_ItemCreated"

        Public Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.DataGridItemEventArgs)
        If e.Item.ItemType = ListItemType.Header Then
            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 = "服务<br>次数"

            tcl.Add(New TableHeaderCell)
            tcl(4).RowSpan = 2
            tcl(4).Text = "用户<br>修改"

            tcl.Add(New TableHeaderCell)
            tcl(5).RowSpan = 2
            tcl(5).Text = "健康<br>清单"

            tcl.Add(New TableHeaderCell)
            tcl(6).ColumnSpan = 4
            tcl(6).Text = "个人疾病危险性评价</td><td colspan='1' rowspan='2' align=center

valign=middle bgcolor='#0082C6'><font color='#ffffff'>管理<br>处方</font></td><td

rowspan='2' align=center valign=middle bgcolor='#0082C6'><font color='#ffffff'>汇总<br>报告

</font></td><td rowspan='2' align=center valign=middle bgcolor='#0082C6'><font

color='#ffffff'>重点<br>提示</font></td></tr><tr><td bgcolor='#848284' align='center'

valign='middle'><font color='#ffffff'>糖尿病</font></td><td bgcolor='#848284' align='center'

valign='middle'><font color='#ffffff'>中风</font></td><td bgcolor='#848284' align='center'

valign='middle'><font color='#ffffff'>冠心病</font> </td><td bgcolor='#848284'

align='center' valign='middle'><font color='#ffffff'>肺癌</font>"
          
        End If
    End Sub 'DataGrid1_ItemCreated
             关键的部分是
            tcl.Add(New TableHeaderCell)
            tcl(6).ColumnSpan = 4
            tcl(6).Text = "个人疾病危险性评价</td><td colspan='1' rowspan='2' align=center

valign=middle bgcolor='#0082C6'><font color='#ffffff'>管理<br>处方</font></td><td

rowspan='2' align=center valign=middle bgcolor='#0082C6'><font color='#ffffff'>汇总<br>报告

</font></td><td rowspan='2' align=center valign=middle bgcolor='#0082C6'><font

color='#ffffff'>重点<br>提示</font></td></tr><tr><td bgcolor='#848284' align='center'

valign='middle'><font color='#ffffff'>糖尿病</font></td><td bgcolor='#848284' align='center'

valign='middle'><font color='#ffffff'>中风</font></td><td bgcolor='#848284' align='center'

valign='middle'><font color='#ffffff'>冠心病</font> </td><td bgcolor='#848284'

align='center' valign='middle'><font color='#ffffff'>肺癌</font>"
            
现在Table中设计出来结构,然后将双引号变成单引号,在添加到TableHeaderCell.text中就可以了。多复杂的都可以实现。




……

相关阅读