Enter your email address:

    Delivered by FeedBurner

Tuesday, January 20, 2009

Delphi: Assign Display Format and Edit Format of a Table Field "MANUALLY"

It's best to always optimize your Delphi program size into the smallest size as it can be.

When you are working with lots of tables, queries and datasets, you might end up with a lot of those database-related components. And one reason that makes a programmer add all of those components is to just fill in the "DisplayFormat" and "EditFormat" properties of numeric, integer and date fields of a table.

So, to save all those bytes, you can simply do it manually.

TFloatField(Table1.FieldByName('amount')).DisplayFormat := '#,0.00;- #,0.00;0.00';

TFloatField(Table1.FieldByName('amount')).EditFormat := '#0.00';



TFloatField = says the field is of numeric format.

DisplayFormat = to set the field's format when the record is in display/view mode

EditFormat = to set the field's format when the record is in edit and insert mode

#,0.00;- #,0.00;0.00 = the format you can set when on display/view mode. The format for creating a format like this is positive value;negative value;zero or no value separated with semicolon

#0.00 = the format you can set when on edit and insert mode.

0 comments:

Post a Comment

About Me

My photo
I provide health supplements, adult wellness products, glutathione, and other merchandise. Please visit my online shop at: http://luckycowshop.blogspot.com/