首页 > Windows开发 > 详细

表格合并单元格【c#】

时间:2021-09-06 23:53:25      阅读:5      评论:0      收藏:0      [点我收藏+]

gridBranchInfo.DataSource = dtBranchViewList;
gridBranchInfo.DataBind();
Random random = new Random();
Color[] color = {Color.DarkSalmon, Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Brown, Color.Violet, Color.Honeydew,Color.IndianRed };

if (gridBranchInfo.Rows.Count > 0)
{
TableCell gridmd = gridBranchInfo.Rows[0].Cells[1];
for (int i = 1; i < gridBranchInfo.Rows.Count; i++)
{
TableCell gmid = gridBranchInfo.Rows[i].Cells[1];
if (gridmd.Text == gmid.Text)
{
gmid.Visible = false;
if (gridmd.RowSpan == 0)
{
gridmd.RowSpan = 1;
}
gridmd.RowSpan++;
gridmd.Font.Bold = true;
gridmd.ForeColor = color[random.Next(1, 7)];
gridmd.CssClass = "solids";
gridmd.VerticalAlign = VerticalAlign.Middle;
}
else
{
gridmd = gmid;
}
}
}

 


添加颜色:
<style type="text/css">

.solids {
border: 1px solid;
border-left: 2px solid;
}
</style>

表格合并单元格【c#】

原文:https://www.cnblogs.com/liuguiqing/p/15233367.html

(0)
(0)
   
举报
评论 一句话评论(0
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!