RepositoryItem emptyRepositoryItem = new RepositoryItem();
RepositoryItemCheckEdit checkEdit = new RepositoryItemCheckEdit();
RepositoryItemTextEdit textEdit = new RepositoryItemTextEdit();
RepositoryItemComboBox repositoryItemComboBox = new RepositoryItemComboBox();
private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
{
var gridView = sender as GridView;
if (e?.Column?.Name == "checkEdit")
{
e.RepositoryItem = e.RowHandle % 2 == 1 ? checkEdit : emptyRepositoryItem;
}
else if (e?.Column?.Name == "textEdit")
{
e.RepositoryItem = gridView.RowCount - 6 == e.RowHandle || e.RowHandle == 1 ? textEdit : emptyRepositoryItem;
}
else if (e?.Column?.Name == "repositoryItemComboBox")
{
e.RepositoryItem = e.RowHandle == gridView.RowCount - 1 || e.RowHandle == 0 || e.RowHandle % 2 != 0
? emptyRepositoryItem
: repositoryItemComboBox;
}
}
- DevExpress中的表格控件(GridControl、TreeList、Gantt、spreadsheet),理论上都可通过CustomRowCellEdit事件每一个单元格设置独有的编辑控件类型,可以根据具体的需求调整。