GridControl 合并单元格

修改GridView的OptionsView.AllowCellMerge属性为True;

1
gridView.OptionsView.AllowCellMerge == true;

在GridView控件的CellMerge事件中加入以下方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
private void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e)
{
if (e.Column.FieldName == "docKey" || e.Column.FieldName == "docCaption") //docKey和docCaption为需要合并单元格的列
{
DevExpress.XtraGrid.Views.Grid.GridView gridView = sender as DevExpress.XtraGrid.Views.Grid.GridView;
if (gridView != null)
{
string value1 = (string)gridView_FillInParam.GetRowCellValue(e.RowHandle1, e.Column);
string value2 = (string)gridView_FillInParam.GetRowCellValue(e.RowHandle2, e.Column);
e.Merge = value1 == value2;//是否执行合并的条件
e.Handled = true;
}
}
else
{
e.Merge = false;
e.Handled = true;
}
}

另:

Appearance.HorzLine.BackColor 水平线颜色

Appearance.VertLine.BackColor 竖直线颜色

GridControl 添加下拉框控件

1
2
3
4
5
6
7
8
9
10
11
if (caption != null && caption is List<string>)
{
List<string> captionLst = caption as List<string>;
RepositoryItemComboBox repositoryItemComboBox = new RepositoryItemComboBox();
repositoryItemComboBox.Items.AddRange(captionLst);
repositoryItemComboBox.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; //不可输入
//GridControl
//gridView.Columns[dataColumn.ColumnName].Properties.RowEdit = repositoryItemComboBox;
//VGridControl
vGridControl_Info.Rows["row" + dataColumn.ColumnName].Properties.RowEdit = repositoryItemComboBox;
}