Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tdbgrid with ado - formatting columns

Status
Not open for further replies.

lennynuts

Programmer
Oct 12, 2006
9
GB
I am connecting to an access database at runtime, not design time so I cant use the ide to set column parameters. This works ok, but there is no formatting on the numeric fields. How can I set it in code,
TIA,
Lenny
 
You can set it up in design time, set up all the connections manually (delete them afterwards) and format your columns. The ADO component will remember them.

If you still want to set up all the formatting at runtime, access the TField object associated with each field in your dataset. Have a look in the help for all the properties available.

eg.

Code:
ADOTable1.FieldByName('CustomerID').Alignment := taRightJustify;
 
Yes, I solved it wth this

with adotable1 do
begin
TFloatField(FieldByName('fname')).DisplayFormat:='######.00';
end;

Thanks for pointing me in the right direction,
 
Not that is has anything to do with your problem, but why would you want to format a first name like that?

Code:
TFloatField(FieldByName([b]'fname'[/b])).DisplayFormat:='######.00';

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
I just put fname in to signify a field name, it is actually a currency field I'm formatting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top