1

我有一个 Devexpress DataGridView。名为 TEST 的列设置为使用RepositoryItemTextEdit

 RepositoryItemTextEdit te = new RepositoryItemTextEdit();
 _grd.RepositoryItems.Add(te);
 _rgv.Columns["TEST"].ColumnEdit = te;
 te.ContextImage = myimage;

此代码为列中的所有单元格设置图像。如何在循环中单独编辑单元格图像?

4

2 回答 2

2

处理CustomDrawCell事件。

private void _grd_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) {
  if (e.Column.FieldName == "TEST") {
    var te = (e.Cell as GridCellInfo).ViewInfo as TextEditViewInfo;
    te.ContextImage = GetCustomImageForThisRow(); // <-- your custom logic 
  }
}
于 2019-04-18T08:39:43.997 回答
1

如果您的图像数量有限,我建议您创建一些存储库项目并有条件地将它们分配给GridView中的单元格。CustomRowCellEdit事件。

如果您需要多个不同的图像,请使用Cells文章的Cell Icons部分中描述的方法之一。

于 2019-04-18T06:53:33.543 回答