How do I convert a TextBox to int or is there a box inside WPF that supports only numbers?
Asked
Active
Viewed 2.8k times
2 Answers
13
To convert string to int you can use, Parse
:
string text = "1234";
int value = int.Parse(text);
Or you could use NumericUpDown control.

Alex Aza
- 76,499
- 26
- 155
- 134
-
i don't find numericupdown in wpf, but the parse works perfectly. – divfe May 15 '11 at 16:21
-
@divfe - It is not part of standard WPF controls, I provided the URL to the Extended WPF toolkit. – Alex Aza May 15 '11 at 16:25
1
If you only want numeric input, you might be better off with numbericupdown. Of course, you could just validate the input using tryparse...

soandos
- 4,978
- 13
- 62
- 96