WinForms Data Grid - Display icons in grid cells

This example demonstrates various techniques to display images/icons within data cells. For example, the CustomDrawCell event is handled to draw icons within CustomDraw column cells.

private void GridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) {
    if (e.RowHandle != GridControl.NewItemRowHandle && e.Column.FieldName == "CustomDraw") {
        e.DisplayText = string.Empty;
        e.DefaultDraw();
        e.Cache.DrawImage(GetImageFromResource(e.CellValue.ToString()), e.Bounds.X, e.Bounds.Y);
    }
}

Read the following help topic for more information: Cell Icons - How to Display an Image in a Grid Cell

Files to Review

See Also