带有多行编辑框的 CMFCPropertyGridProperty

发布于 2024-10-31 02:39:40 字数 497 浏览 4 评论 0原文

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

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗琴音 2024-11-07 02:39:40

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

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.

濫情▎り 2024-11-07 02:39:40

您可以像在旧式编辑器中一样执行此操作(替换“\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");
}

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");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文