0

How to create a multi line property with edit box? I need one more property that will show text in multi line box.

CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Appearance"));
pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Name"), (_variant_t) _T(""), _T("Specifies the text that will be displayed in the property")));
pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Comments"), (_variant_t) _T(""), _T("Specifies the text that will be associated with the property")));
m_wndPropList.AddProperty(pGroup1);
baraban
  • 455
  • 1
  • 6
  • 18

2 Answers2

0

You can do it like in old style editors (replacing "\n","\n" so user can divide lines by "\n"):

Initialization:

CString s = m_initial_params.m_info;
s.Replace("\n","\\n");
CMFCPropertyGridProperty* pProp = new 
CMFCPropertyGridProperty(misc_get_str_my(IDS_INFO), 
            (_variant_t) s, misc_get_str_my(IDS_INFO));
pProp->SetData(E_PROPERTY_DATA::OBJ_INFO);
pPropCtrl->AddProperty(pProp);

Reading Value:

int nProperty = pProperty->GetData();
if(E_PROPERTY_DATA::OBJ_INFO == nProperty)
{
    m_initial_params.m_info = pProperty->GetValue().bstrVal;
    m_initial_params.m_info.Replace("\\n","\n");
}
Danil
  • 701
  • 8
  • 7
0

It seems that multi-line properties are not implemented in MFC Property Grid. You can create a custom property with a button and show your own dialog with multi-line edit control when user click this button.

Michael
  • 61
  • 1