uoah
uoah

Reputation: 169

Issue with textbox rounding a number

I have the following code:

txtbox1.Text = listView1.SelectedItems[0].SubItems[11].Text;

The value of the selected item of the listview is "33,5" but when the code reachs this line, in the textbox writes 34,00.

I don't know why if there's a text inside a text, I have tried convertingo to decimal before asing to the textbox but still put 34,00. I've tried too puting 33.5 instead of 33,5 but then the code writes in the textbox: 3350,0.

What can I do?

Thanks

Upvotes: 1

Views: 143

Answers (1)

Davide Piras
Davide Piras

Reputation: 44595

try this:

string number = listView1.SelectedItems[0].SubItems[11].Text;

and check in debug mode what number contains.

I am convinced you have the right value in there, a simple string, but the txtbox1 is applying certain formatting on text change. You should find this out and fix the way content of txtbox1 is formatted after assignment.

Upvotes: 1

Related Questions