Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

c++ builder -formating DBEdit

Posted on 2003-03-06
4
Medium Priority
?
883 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

564 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