1
private void DataGrid_Join()
2
{
3
int iRow, iSpan=1, iRow_Start=0; //定义当前行数,合并行数,合并开始行标志
4
string sSText, sNText; //比较源文本,比较下一文本
5![](/Images/OutliningIndicators/InBlock.gif)
6
for(iRow=0; iRow<DataGrid1.Items.Count-1; iRow++)
7
{
8
sSText = DataGrid1.Items[iRow].Cells[1].Text;
9
sNText = DataGrid1.Items[iRow+1].Cells[1].Text;
10
if(sSText == sNText)
11
{
12
DataGrid1.Items[iRow+1].Cells[2].Visible = false;
13
iSpan++;
14
}
15
else
16
{
17
iSpan = 1;
18
iRow_Start = iRow+1;
19
}
20
DataGrid1.Items[iRow_Start].Cells[2].RowSpan = iSpan;
21
}
22![](/Images/OutliningIndicators/InBlock.gif)
23
//清除临时列
24
DataGrid1.Columns[1].Visible = false;
25
}
26![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
26
![](/Images/OutliningIndicators/None.gif)