Search code examples
c#.netwinformsdevexpressxtraeditors

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

 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?


Solution

  • 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.CustomRowCellEdit event.

    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.