开发者

DataGridView TextBox value conversion to decimal (with fixed point)

开发者 https://www.devze.com 2023-03-02 12:56 出处:网络
In a TextBox in DataGridView when I type in example 50.30 and then I convert it to decimal using: decimal money = Convert.ToDecimal(dgv.Rows[0].Cells[2].Value);

In a TextBox in DataGridView when I type in example 50.30 and then I convert it to decimal using:

decimal money = Convert.ToDecimal(dgv.Rows[0].Cells[2].Value);

it conver开发者_JAVA百科ts to 5030, not to 50.30... :(

or if it's 50 I need it to be converted to 50,0000 like the money type in sql server.

Any help?

thank you


You should use

Convert.ToDecimal(Object value, IFormatProvider provider)

Where provider is instace of your class.

0

精彩评论

暂无评论...
验证码 换一张
取 消