Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Database Null Cell Values

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
Halftime



Joined: 12 Nov 2006
Posts: 7
Location: Charlotte NC

PostPosted: Sun Nov 12, 2006 10:18 pm    Post subject: Database Null Cell Values Reply with quote

I am migrating an existing application from vb6 to c# and using the virtual grid - Its Great BTW.

I have 2 questions:

QUESTION #1 The issue I'm having is regarding the display and format of cells that have a NULL (DBNull) value. Most of the time I have values, but some times there may not be a valid / relevant value just for some rows.

When the data exists I would like to format it (Its type double, so I format it with commas, etc) . But when its Null I need it to be completely Blank.

I did not find much info. in the help files or example on formatting.


QUESTION #2 - I need to dynamically define the which columns get displayed - I can hide them by setting the Active property to False, but they still appear in the Column list selection. How do I keep them from showing up in the column selection list too ?


Any help / suggestions would be appreciatedl.

Thanks,
Mike
_________________
Michael Miller
HalfTime Technologies
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Nov 13, 2006 12:36 am    Post subject: Reply with quote

Quote:
QUESTION #1 The issue I'm having is regarding the display and format of cells that have a NULL (DBNull) value. Most of the time I have values, but some times there may not be a valid / relevant value just for some rows.

When the data exists I would like to format it (Its type double, so I format it with commas, etc) . But when its Null I need it to be completely Blank.


I assume you are probably binding to data from an ADO.NET dataset - is that correct?

Virtual Tree will handle display of DBNull values. You can simply set the Format property of the CellBinding (in the VirtualTree editor) eg

Code:
{0:$#,##0.00}


In this case if the value is DbNull the displayed text will be Null. Note that the "{0:}" is the placeholder for the value to displayed - with the format string specified after the colon. You can also include text outside the brackets. This however will be displayed always regardless of the value eg

Code:
${0:#,##0.00}


Will display a dollar sign even if the value is DBNull

Quote:
QUESTION #2 - I need to dynamically define the which columns get displayed - I can hide them by setting the Active property to False, but they still appear in the Column list selection. How do I keep them from showing up in the column selection list too ?


It depends exactly on what you are trying to achieve. If you would like the columns displayed to depend on the currently selected row (or some other criteria) then you should set the ContextSensitive property of the column to true. By default when this is true the column is only displayed if the currently focus row supports (ie has a binding for) the column. If you want a different criteria for when a column should be "InContext" then you can handle the GetColumnInContext event to programmatically determine this.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group