PC Review


Reply
Thread Tools Rate Thread

Datagridview image column nulls

 
 
Earl
Guest
Posts: n/a
 
      19th Nov 2006
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.


 
Reply With Quote
 
 
 
 
Bart Mermuys
Guest
Posts: n/a
 
      19th Nov 2006
Hi,

"Earl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


>
>



 
Reply With Quote
 
Earl
Guest
Posts: n/a
 
      19th Nov 2006
Thanks Bart, that helped.

"Bart Mermuys" <(E-Mail Removed)> wrote in message
news:18%7h.193089$(E-Mail Removed)...
> Hi,
>
> "Earl" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>
>
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagridview image column nulls Earl Microsoft ADO .NET 2 19th Nov 2006 08:34 PM
Setting Image in DataGridView image column? David Veeneman Microsoft C# .NET 3 24th Jul 2006 05:55 PM
Insert an Image to a dataGridView column Marc Solé Microsoft C# .NET 2 26th May 2006 04:53 PM
Image in DataGridView Button Column =?Utf-8?B?Q29jbw==?= Microsoft Dot NET Framework Forms 1 25th May 2006 12:11 PM
DataGridView Image Column mj2736@yahoo.com Microsoft Dot NET Framework Forms 1 17th May 2006 09:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:47 AM.