views:

301

answers:

1

Hi All,

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?

Thanks...

+3  A: 

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, 
        _T("0123456789"));

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

Steve Beedie