码迷,mamicode.com
首页 > 其他好文 > 详细

gridControl根据值合并单元格

时间:2017-06-15 17:17:45      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:ring   tco   设置   根据   handle   column   str   boolean   amp   

在DevExpress中GridControl中纵向合并单元格只需要设置
this.gridView1.OptionsView.AllowCellMerge = true;
列默认是可合并的,若设置某列不可合并可设置该列为
this.gridColumn1.OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False;

private void grvDetail_CellMerge(object sender, CellMergeEventArgs e)
{
GridView view = sender as GridView;
string firstColumnFieldName = "EQPCode", secondColumnFieldName = "EQPName";

if (e.Column.FieldName == firstColumnFieldName)
{
string valueFirstColumn1 = Convert.ToString(view.GetRowCellValue(e.RowHandle1, view.Columns[firstColumnFieldName]));
string valueFirstColumn2 = Convert.ToString(view.GetRowCellValue(e.RowHandle2, view.Columns[firstColumnFieldName]));
string valueSecondColumn1 = Convert.ToString(view.GetRowCellValue(e.RowHandle1, view.Columns[secondColumnFieldName]));
string valueSecondColumn2 = Convert.ToString(view.GetRowCellValue(e.RowHandle2, view.Columns[secondColumnFieldName]));

e.Merge = valueFirstColumn1 == valueFirstColumn2 && valueSecondColumn1 == valueSecondColumn2;
e.Handled = true;
}
}

gridControl根据值合并单元格

标签:ring   tco   设置   根据   handle   column   str   boolean   amp   

原文地址:http://www.cnblogs.com/smallsunand/p/7018707.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!