Search code examples
c++mfc

MFC PropertyGrid will not expand on user click (disabled)


I'm actually working with the MFC Property grid and, I wish to allow the user to expand the Items.

Basically I'm adding items to a MFC Property grid

CMFCPropertyGridProperty* mParent = new CMFCPropertyGridProperty(_T("cycle"));
mGrid.AddProperty(mParent);
mParent->AddSubItem(new CMFCPropertyGridProperty(_T("Id"),        _T("test")));
mParent->AddSubItem(new CMFCPropertyGridProperty(_T("Name"),      _T("test")));
mParent->AddSubItem(new CMFCPropertyGridProperty(_T("DateStart"), _T("test")));
mParent->AddSubItem(new CMFCPropertyGridProperty(_T("DateStop"),  _T("test")));

Basically I want all Items to be nonExpanded when I add them but I want the user to be able to expand them However, it seems that the default behavior is to prevent the user from expanding Items...

So far I've tried Enable(true) and EnableActiveAccessibility() but those doesn't seem to work...

Any idea which property I should set?

Thanks!


Solution

  • It's not very obvious, but you need to call CMFCPropertyGridProperty::Expand with the bExpand parameter as FALSE!

    Parameters [in] bExpand TRUE to expand the property; FALSE to collapse the property. The default value is TRUE.