Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2004, 11:22 AM
hermannhass hermannhass is offline
Junior Member
 
Join Date: Apr 2002
Posts: 9
Default NULL as "0" in Dbgrid

hello
how can i Display a NULL-value as "0" in my dbgrid.
If the numericvalue is NULL, i want to display "0".
How can i do?
thanks hermann
Reply With Quote
  #2  
Old 02-10-2004, 03:55 PM
HELMONT HELMONT is offline
Senior Member
 
Join Date: Feb 2001
Posts: 368
Default RE: NULL as "0" in Dbgrid

why don't you update all the Null to 0 in the DB?

a simple Update query will do the job
Reply With Quote
  #3  
Old 02-10-2004, 04:25 PM
HTML HTML is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,977
Default RE: NULL as "0" in Dbgrid

Hello :-)

I suppose you can use the OnGetText event of the TField to do the job, this will affect the way the field's data is displayed in the data-aware controls. Double click or right click the TTable or TQuery and select "Fields Editor..." , select the field you want, now in the Object Inspector you should find a OnGetText event for the TField, use some code that looks something like this:

if Sender.IsNull then
Text := '0'

else
Text := Sender.AsString;

You can also use the OnSetText event in a similar fashion to actually save data in any format you wish.
Reply With Quote
  #4  
Old 02-10-2004, 08:00 PM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default RE: NULL as "0" in Dbgrid

Set the DisplayFormat property for this numeric field

With best regards, Mike Shkolnik
http://www.scalabium.com
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 05:30 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.