Re: Displaying Currency on a VB . NET windows form
- From: VBStudioLosAngeles <VBStudioLosAngeles@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 9 Jul 2009 11:35:01 -0700
Thank you, Morten.
I am not exactly clear on where to put this, in the code behind forms ?
Why am I able to "format" a date object easily with the "Format" property,
and this is much more unintuitive ?
Isn't there a property that just can be set on how to display the Money, as
it should be displayed in form for intutivitive and easy reading?
I am confused !
Thank you !
"Morten Wennevik [C# MVP]" wrote:
In .Net the database type 'money' would translate to the .Net type 'decimal'..
Calling decimal.ToString("c") would create a currency formatted string
object containing the actual value as well as a currency symbol from the
current culture. You can put this string object in a TextBox. If you only
want the integer value you can use c0 as the format to specify 0 decimal
places. The value would be rounded.
decimal d = 12.87m;
textBox1.Text = d.ToString("c0", CultureInfo.GetCultureInfo("en-US")); // $13
Specifying the CultureInfo is optional, but on my Norwegian system it would
otherwise output "kr 13";
--
Happy Coding!
Morten Wennevik [C# MVP]
"MS Access Question" wrote:
If it were a string, I would understand this. It's not a string. It is a SQL
Server Money type column.
Why is there not a "picture" or "format" property to put in something like
$#,### similar to MS Access?
A date field has a "format" property. I would think it would be similar to
this. Can you advise ?
Thanks,
"Gregory A. Beamer" wrote:
=?Utf-8?B?TVMgQWNjZXNzIFF1ZXN0aW9u?=
<MSAccessQuestion@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:07D1697D-545F-442A-9A8C-6DF74192AA29@xxxxxxxxxxxxx:
I have a SQL Server Table, with a Money/Currency type.
I wish to display it with a dollar sign and however much it is without
any decimals.
I tried using the Masked Text box control, but no luck.
How do I display this value on a Windows Form in Visual Studio 2008 ?
Thanks
One option is formatting the string you bind to the textbox.
val.ToString("c");
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
*******************************************
- Follow-Ups:
- Re: Displaying Currency on a VB . NET windows form
- From: Morten Wennevik [C# MVP]
- Re: Displaying Currency on a VB . NET windows form
- References:
- Displaying Currency on a VB . NET windows form
- From: MS Access Question
- Re: Displaying Currency on a VB . NET windows form
- From: Gregory A. Beamer
- Re: Displaying Currency on a VB . NET windows form
- From: MS Access Question
- Re: Displaying Currency on a VB . NET windows form
- From: Morten Wennevik [C# MVP]
- Displaying Currency on a VB . NET windows form
- Prev by Date: Re: ClickOnce Generated Shortcut Folder
- Next by Date: Re: Displaying Currency on a VB . NET windows form
- Previous by thread: Re: Displaying Currency on a VB . NET windows form
- Next by thread: Re: Displaying Currency on a VB . NET windows form
- Index(es):
Relevant Pages
|