[英]Iterating through GridView Rows and setting image individually
I have a Devexpress DataGridView.A column named TEST is set to display an image using RepositoryItemTextEdit
我有一个名为TEST的Devexpress DataGridView.A列设置为使用RepositoryItemTextEdit
显示图像
RepositoryItemTextEdit te = new RepositoryItemTextEdit();
_grd.RepositoryItems.Add(te);
_rgv.Columns["TEST"].ColumnEdit = te;
te.ContextImage = myimage;
This code sets the image for all cells in the column.How can i individually edit the cell images in a loop? 此代码设置列中所有单元格的图像。如何在循环中单独编辑单元格图像?
Handle CustomDrawCell
event. 处理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
}
}
If you have a limited number of images, I would recommend creating a few repository items and assign them to cells conditionally in the GridView . 如果您的图像数量有限,我建议您创建一些存储库项目,并在GridView中有条件地将它们分配给单元格。 CustomRowCellEdit event. CustomRowCellEdit事件。
If you need to have a number of different images, use one of the approaches described in the Cell Icons section of the Cells article. 如果需要有许多不同的图像,请使用Cells文章的“ 单元 格图标”部分中描述的方法之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.