Groups | Blog | Home
all groups > dotnet windows forms databinding > november 2006 >

dotnet windows forms databinding : Datagridview image column nulls


Earl
11/19/2006 12:00:00 AM
I've got a datagridview bound to Sql2k database. When the image columns
return null, I get the goofy looking [X] in the column instead of a blank.
Anyone know how to make that just appear as empty instead of the default
[X]? I would also like that to appear as empty when I insert a new row
instead of the [X] if that is possible.

Earl
11/19/2006 3:34:58 PM
Thanks Bart, that helped.

[quoted text, click to view]

Bart Mermuys
11/19/2006 3:55:41 PM
Hi,

[quoted text, click to view]

You can set "someColumn.DefaultCellStyle.NullValue = null;".

[quoted text, click to view]

If you want this too, then *instead* you can handle the cell paint event:

private void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
// suppose 2nd column is a image column
if ((e.ColumnIndex == 1) && (e.FormattedValue == e.CellStyle.NullValue))
{
DataGridViewPaintParts pp = e.PaintParts &
~DataGridViewPaintParts.ContentForeground;
e.Paint(e.ClipBounds, pp);
e.Handled = true;
}
}

HTH,
Greeting


[quoted text, click to view]

AddThis Social Bookmark Button