I\'m working on a WindowsForm project and in my form I have a DataGridView
with a DataGridViewImageColumn
which must show the status
Whenever I have questions on how to do things in a DataGridView I consult Microsoft's FAQ first.
http://www.windowsclient.net/Samples/Go%20To%20Market/DataGridView/DataGridView%20FAQ.doc
Typically what I do in that situation is handle the CellFormatting event to set the image based on the value in the cell.
So I would store my images in something like an image list, then have code in CellFormatting like the following:
private void dgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dgv.Columns[e.ColumnIndex].Name == "status")
{
if (e.Value != null)
{
if (e.Value.ToString() == "1")
{
e.Value = imageList1.Images[1];
}
else
{
e.Value = imageList1.Images[2];
}
}
}
}