Alberto,
Basically, you would want to get the currency format for the system, and
then display that. You can do this easily through the ToString method on
the numeric type that is returned.
You don't need to call the static ToSingle method on the Convert class.
Rather, you can just cast it to your type, like so:
// Cast to the value.
// Float is the C# type alias for Single.
float money = (float) dr("money");
// Write in currency format.
txtMoney.Text = money.ToString("C");
The "C" indicates to use the currency format currently defined for the
thread (which is usually the local machine's setting). Just make sure that
the currency that the amount is in is the same as the one on the local
machine. Otherwise, you will have to get the setting for the region, and
then use that.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Alberto" <al*****@nospam.es> wrote in message
news:Oo**************@TK2MSFTNGP14.phx.gbl...
I have a decimal field in a SQL Server DataBase who stores money and I want
to show it in a TextBox and in a ListView controls in C#.
If I do: txtMoney.Text = Convert.ToSingle(dr["money"]);
I see something like: "4.0000" instead "4.00 ?"
How can I solve this?
Thank you very much