Reputation: 183
How do I convert a TextBox to int or is there a box inside WPF that supports only numbers?
Upvotes: 6
Views: 29170
Reputation: 5146
If you only want numeric input, you might be better off with numbericupdown. Of course, you could just validate the input using tryparse...
Upvotes: 1
Reputation: 78537
To convert string to int you can use, Parse
:
string text = "1234";
int value = int.Parse(text);
Or you could use NumericUpDown control.
Upvotes: 13