Because you are editing data I would use non dataware controls like TEdit
and handle the validating / formatting myself.
I keypress event you could eliminate alpha characters etc being entered.
Then do a final validation on the field before you save the record.
If you want to use dataware controls then you could import the field defs
into the dataset (TQuery) . Then highlight the integer field in question and
you will see in the Object Inspector events GetText and SetText. As an
example
GetText procedure
If Sender.fieldname = 'fieldname' then
Text := FormatFloat('0.00',(Sender.AsInteger /100);
And do something similar for SetText (probably requires validation code) .
Though I still think it's better using a non dataware control for editing.
-----Original Message-----
From: Steven Knight [SMTP:[EMAIL PROTECTED]]
Sent: Tuesday, 28 January 2003 08:43
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Dollar amounts in int fields
Thanks for that but I guess what I was after was where do I hook up
the math
with the fields.
The DBEdit box won't allow entry of non-digits when its pointing at
an Int
field in the database.
The MASKEdit box dosn't point to a database field.
Do I need to use an unbound Edit box and use events to
programmatically load
in values and unload and validate it?
If yes then which events are the best to use?
If no then whats the easy way that I have missed?
Steven
> -----Original Message-----
> From: Alex Kouznetsov [mailto:[EMAIL PROTECTED]]
> Sent: 27 January 2003 4:49 pm
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Dollar amounts in int fields
>
>
> Delphi cannot know that when storing cents in DB you actually
> mean dollars.
> When you retrive data from your DB you need to devide
> retrieved values by 100,
> and when you store data to DB you multiply your dollar values
> by 100 to get
> cents.
> If you use SQL queries to retrive and store data then you can
> just add *100 and
> /100 to your queries.
>
> Alex
>
> ----- Original Message -----
> From: "Steven Knight" <[EMAIL PROTECTED]>
> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
> Sent: Monday, January 27, 2003 10:02 AM
> Subject: [DUG]: Dollar amounts in int fields
>
>
> > Hi all,
> > Don't know if I'm being thick or if this is actually
difficult.
> >
> > My database stores $ amounts in Int fields as cents.
> > I want to edit and display them to the user as a 999.99 format.
> > What facilities should I use in Delphi to achieve this?
> >
> > Steven Knight
> > Analyst / Programmer
> > Environment Canterbury
> > P.O. Box 345, Christchurch
> > phone: (03) 365-3828
> > email: [EMAIL PROTECTED]
> >
> >
> > Hey kids! (and parents) - have fun in the trash zone
> learning to reduce waste
> http://www.ecan.govt.nz/Waste/waste-wastenotwantnot.html
> >
> >
> >
> >
>
**********************************************************************
> > This email and any files transmitted with it are confidential
and
> > intended solely for the use of the individual or entity to whom
they
> > are addressed. If you have received this email in error
> please notify
> > the system manager.
> >
> > The contents of this email and any attachments are not formal
> > policy of Environment Canterbury, unless otherwise stated.
> >
>
**********************************************************************
> >
> >
> --------------------------------------------------------------
> -------------
> > New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> > Web Archive at:
http://www.mail-archive.com/delphi%40delphi.org.nz/
> >
> >
>
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at:
http://www.mail-archive.com/delphi%40delphi.org.nz/
>
Hey kids! (and parents) - have fun in the trash zone learning to
reduce waste http://www.ecan.govt.nz/Waste/waste-wastenotwantnot.html
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please
notify
the system manager.
The contents of this email and any attachments are not formal
policy of Environment Canterbury, unless otherwise stated.
**********************************************************************
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List -
[EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
DISCLAIMER: This electronic message together with any attachments is
confidential. If you are not the intended recipient, do not copy, disclose or
use the contents in any way. Please also advise us by return e-mail that you
have received the message and then please destroy. Carter Holt Harvey is not
responsible for any changes made to this message and / or any attachments after
sending by Carter Holt Harvey. We use virus scanning software but exclude all
liability for viruses or anything similar in this email or any attachment.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/