I want to have a text control that only accepts numbers. (Just integer values like 45 or 366)
What is the best way to do this?
IntCtrl
, Masked Edit Control
, and NumCtrl
are all designed to do just this, with different levels of control. Checkout the wx demo under "More Windows/Controls" to see how they work.
(Or, if you're instead really looking forward to doing this directly with a raw TextCtrl, I think you'd want to catch EVT_CHAR events, test the characters, and call evt.Skip() if it was an allowed character.)