答案 0 :(得分:1)
以下是我自己制定的解决方案......
如果有其他人需要它......
for (int x = 0; x < e.Row.Cells.Count; x++)
{
// work out how wide the cell span should be for this cell
int span = 1;
while (
(x + span < e.Row.Cells.Count) &&
(e.Row.Cells[x + span].Text == e.Row.Cells[x].Text) &&
(e.Row.Cells[x].Text != " ")
)
{
span++;
}
// if we need to span this cell
if (span > 1)
{
// apply the span value to the first cell in the group
e.Row.Cells[x].ColumnSpan = span;
for (int n = 1; n < span; n++)
{
while (n < span)
{
e.Row.Cells[x + span - n].Visible = false;
n++;
}
}
// skip to the next cell past the end of the span
x += span - 1;
}
}