I want enter number digits into textbox and textbox will automaticaly convert this digits itno currncy
like this if i want enter 120 , i want textbox convert it 1,20 how to make code for it ?

TEXTBOX FORMATTING in a single statement.

Textbox formating using a single line of code. I Hope this helps.

Example :


The last parameter "C" formats the UnitCost field to Currency Format. The table below is a list of string formatting parameters that you could use.

Table of Formats
Type                            Format                        Example
Currency                       C                                 $1,234.50

Exponential                    E                                 1.234.50E+004

Percentage                    P                                  45.6%

Fixed Decimal                F?                                ?=no.decimals Ex. F3=123.4000

ShortDate                     d                                  M/d/yyyy

LongDate                      D                                 MMMM dd, yyyy

Long Date 
Short Time                    f                                  dddd,MMMM dd, yyyy HH:mm aa

Long Date 
Long time                      F                                 dddd,MMMM dd yyyy HH:mm:ss:aa

Month & Day                 M                                 MMMM dd

General                        G                                 Date & Time format depends on system locale settings

References http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/c860168f-46e5-4786-a68d-ac69c6a7a248/

Edited 4 Years Ago by Majestics

if you want to display the value in a textbox:
sometextbox.text = String.Format("{0:C}", yourvalue);

if you are wantign to convert it to store the value in a table, you have to cast the value to a decimal:
someVariable = Decimal..Parse(yourValue).

This article has been dead for over six months. Start a new discussion instead.