VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#教程之gridcontrol 根据某一列数据来控制其他列合

首先需要属性栏中设置这一列可以合并,再在CellMerge方法中写

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
private void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e)
       {
           if (e.Column.FieldName == "题目" || e.Column.FieldName == "分值" )
           {
               string valueFirstColumn1 = Convert.ToString(gridView1.GetRowCellValue(e.RowHandle1, gridView1.Columns["三级标题"]));
               string valueFirstColumn2 = Convert.ToString(gridView1.GetRowCellValue(e.RowHandle2, gridView1.Columns["三级标题"]));
               if(valueFirstColumn1 == valueFirstColumn2 )
               {
                   e.Merge =true ;
                   if (e.RowHandle2 > maxhandle && e.Column.FieldName == "题目")
                   {
                       string lastValue = gridView1.GetRowCellValue(e.RowHandle1, gridView1.Columns["题目"]).ToString();
                       string repeatValue = gridView1.GetRowCellValue(e.RowHandle2, gridView1.Columns["题目"]).ToString();
                       gridView1.SetRowCellValue(e.RowHandle1, gridView1.Columns["题目"], lastValue + "\n" + repeatValue);
                       maxhandle = e.RowHandle2;
                       int fenzhiValue= Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle1, gridView1.Columns["分值"]));
                       int fenzhiRepeatValue= Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle2, gridView1.Columns["分值"]));
                       gridView1.SetRowCellValue(e.RowHandle1, gridView1.Columns["分值"], fenzhiValue + fenzhiRepeatValue);
 
                   }
                 
               }
               e.Handled = true;
           }
        
       }