Reputation: 179
How can set icon in Dev express data grid depending on the value returning from Database
Upvotes: 4
Views: 19824
Reputation: 18792
Here are the steps.
All the above can be done in the designer. Then do the following
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
if (e.Column == colImage1 && e.IsGetData) {
string someValueFromDatabase = (string)gridView1.GetRowCellValue(e.RowHandle, colOne);
if (someValueFromDatabase == "a") {
//Set an icon with index 0
e.Value = imageCollection1.Images[0];
} else {
//Set an icon with index 1
e.Value = imageCollection1.Images[1];
}
}
}
The key here is handling the CustomUnboundColumnData and the repositoryItemPictureEdit.
Upvotes: 18