?
Solved

c++ builder -formating DBEdit

Posted on 2003-03-06
4
Medium Priority
?
826 Views
Last Modified: 2008-02-01
What do i need to do in order to make a TDBEdit box to display floating point number as a currency, that is, if the user enters a number like 1234.5 that when he exits the field (box) the number is displayed like 1,234.50? I am using the InterBase database.
0
Comment
Question by:vukotic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:BTecho
ID: 8082757
Hello.

You can try and set the TField's DisplayFormat to #.00.

You can also control the display format using the TField's OnGetText and OnSetText event handlers.

See C++Builder help for more info.

0
 
LVL 2

Accepted Solution

by:
BorlandMan earned 800 total points
ID: 8085581
Ok, I think I can help you out here.

I'm going to assume you have a table and maybe your using TTable or TQuery.  One way you can do this is create persistent fields.

for a ttable (or tquery), in the designer (IDE), you right click on the component. Pick from the popup menu Add fields. You should see a list of fields for that table. Select the fields you want to use. Click Ok.

You should see a window popup which (little one), which shows the fields you added. (neat trick) click on the field name and drag it into your form. If it is a number of text, C++ builder will manufacture a TEdit control for and even create a label - talk about rad eh!... vb doesn't even do that.

Ok, now go back to the window with the list of fields you added, click ont he field you want to be currency. press F11 to get to the property inspector.  Find the property called display format and enter in something like ###,###,###.00
(check out help - just click in the 'displayFormat' property and press F1) to get a description of how these 'masks' work.

it should display with commas now. If want the $ in front, you can simply set the currency property in the inspector for the field to 'true' and $ and commas will appear.

Hope that helps,
Sincerely,
J


0
 

Author Comment

by:vukotic
ID: 8087149
Strange thing is that 10 minutes after i have desperatelly posted this question, i remembered that i have done it last year just by setting the currency property to true and the global variable CurrencyString to €. I have completely forgot that fields editor exists. Anyway, this was a very helpfull answer, i didn't know about the possibillities of the DisplayFormat property.
Thanks!!
0
 
LVL 2

Expert Comment

by:BorlandMan
ID: 8091107

Vukotic,
glad I was able to help.

sincerely,
J
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question