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.

Re: Datagridview image column nulls by Bart

Bart
Sun Nov 19 09:55:41 CST 2006

Hi,

"Earl" <brikshoe@newsgroups.nospam> wrote in message
news:u2eWSk7CHHA.992@TK2MSFTNGP03.phx.gbl...
> 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]?

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

> I would also like that to appear as empty when I insert a new row instead
> of the [X] if that is possible.

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


>
>



Re: Datagridview image column nulls by Earl

Earl
Sun Nov 19 14:34:58 CST 2006

Thanks Bart, that helped.

"Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message
news:18%7h.193089$Cf6.2929762@phobos.telenet-ops.be...
> Hi,
>
> "Earl" <brikshoe@newsgroups.nospam> wrote in message
> news:u2eWSk7CHHA.992@TK2MSFTNGP03.phx.gbl...
>> 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]?
>
> You can set "someColumn.DefaultCellStyle.NullValue = null;".
>
>> I would also like that to appear as empty when I insert a new row instead
>> of the [X] if that is possible.
>
> 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
>
>
>>
>>
>
>