C++ – CMFCPropertyGridProperty numeric input


I'm using MFC feature pack and I have a dockable properties window. How do I restrict the user from typing any other characters but numbers alone in the values field?


Best Solution

One of the constructors for the CMFCPropertyGridProperty class has a parameter lpszValidChars which you can use to limit the characters that can be input. e.g.

CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Numeric Value"),
        (_variant_t) 250l, _T("A numeric value"), NULL, NULL, NULL, 

The last parameter here limits the characters that can be entered.