User (Old forums)MemberJune 9, 2006 at 10:43 amPost count: 23064
I have been looking at how to do this for weeks now and find this exceedingly complicated.
I am simply trying to replace the content of a cell with an icon, displaying a different icon depending on the content of the cell.
For example, if a cell contains word “Running” I would like to show a little icon of a runner, if the cell says “Paused” and icons of a ” sign.
The examples I found so far appear very complicated, and seem to require either storage of the image in the db or otherwise difficult loading mechanism.
Does anyone have any code snipets I could just plug-and-run (Pardon the pun) that would help me accomplish the above.
Thanks in advance,
Imported from legacy forums. Posted by paullepa (had 3889 views)User (Old forums)MemberJune 12, 2006 at 11:53 amPost 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)
if( ( bool )e.DataRow.Cells[ “Discontinued” ].Value == false )
icon = new Bitmap( Application.StartupPath + @”\Uncheck.ico” );
icon = new Bitmap( Application.StartupPath + @”\Check.ico” );
e.DataRow.Cells[ “column1” ].Value = icon;
Imported from legacy forums. Posted by André (had 485 views)User (Old forums)MemberJune 18, 2006 at 11:34 amPost count: 23064
I tried this, but when i inserted an unbound column, there was no option for dataType “Bitmap”.
Imported from legacy forums. Posted by belay (had 305 views)User (Old forums)MemberJune 19, 2006 at 5:13 pmPost count: 23064
This should be available : System.Drawing.Bitmap. Which version of the grid are you using?
Imported from legacy forums. Posted by André (had 261 views)User (Old forums)MemberJune 20, 2006 at 2:56 amPost count: 23064
Imported from legacy forums. Posted by belay (had 355 views)
- You must be logged in to reply to this topic.