CMFCPropertyGridProperty具有多行编辑框

时间:2011-04-07 21:36:07

标签: c++ mfc mfc-feature-pack

如何使用编辑框创建多行属性?我需要一个将在多行框中显示文本的属性。

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);

2 个答案:

答案 0 :(得分:0)

似乎多行属性未在MFC属性网格中实现。您可以使用按钮创建自定义属性,并在用户单击此按钮时显示您自己的带有多行编辑控件的对话框。

答案 1 :(得分:0)

您可以像旧式编辑器那样(替换" \ n"," \ n"因此用户可以按" \ n"来划分行):

初​​始化:

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);

阅读价值:

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");
}