Home Forums WinForms controls Xceed Grid for WinForms Icons in a cell Reply To: Icons in a cell

User (Old forums)
Member
Post count: 23064

The best way to accomplish this is to add an unbound column, which you set the data type to bitmap, and then use this column to display the icon, while hiding the bound column. You can have a set of icons in your project folder, and you simply access these at runtime, in the AddingDataRow event.

So in the form_load you would do something like this :

gridControl1.AddingDataRow += new AddingDataRowEventHandler(gridControl1_AddingDataRow);
gridControl1.Columns[ “Discontinued” ].Visible = false;

In the event handler, do something like this :

private void gridControl1_AddingDataRow(object sender, AddingDataRowEventArgs e)
{
Bitmap icon;
if( ( bool )e.DataRow.Cells[ “Discontinued” ].Value == false )
icon = new Bitmap( Application.StartupPath + @”\Uncheck.ico” );
else
icon = new Bitmap( Application.StartupPath + @”\Check.ico” );
e.DataRow.Cells[ “column1” ].Value = icon;
}

Imported from legacy forums. Posted by André (had 485 views)