Print Page | Close Window

Multiple line GridItem text?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=2298
Printed Date: 03 May 2024 at 9:56am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Multiple line GridItem text?
Posted By: CGrant
Subject: Multiple line GridItem text?
Date Posted: 30 May 2005 at 4:49pm

I've been looking for a way to add a textual grid item that has more than one line of text - e.g. an address or a user's short free format comment.

Any pointers would be appreciated

Colin




Replies:
Posted By: Boyd
Date Posted: 31 May 2005 at 7:30am
I've been using the PropertyGrid for a while, and I'm 99% sure there's no way to do this.  I suggest submitting a feature request to Codejock.


Posted By: CGrant
Date Posted: 31 May 2005 at 11:04am

Thanks, I thought that was the case.

I'm waiting to find out if it is an absolute requirement for my project or not. If it is then I'll look to see if there is a way to subclass and owner draw but it sounds like more effort than its worth.

Colin

 



Posted By: CGrant
Date Posted: 08 June 2005 at 5:42pm

I have managed to display multiline text, though editing it still lies ahead.

Basically the code uses owner draw variable height and a class especially for the multi line text.

The property grid creation has to specify the style...


if ( m_wndPropertyGrid.Create( rc, this, IDC_PROPERTY_GRID, LBS_OWNERDRAWVARIABLE ) )

Then adding a property uses a new class


CXTPPropertyGridItem* pSettings = m_wndPropertyGrid.AddCategory(_T("Example"));
strTesting = "Hello\nWorld";
(void)pSettings->AddChildItem(new CMultilineTextGridItem(_T("TESTING"), strTesting, &strTesting));

The class does the minimum possible to get text up (all comments removed for brevity)


class CMultilineTextGridItem : public CXTPPropertyGridItem 
{
public:
    CMultilineTextGridItem(CString strCaption, LPCTSTR strValue = NULL, CString* pBindString = NULL);
     virtual ~CMultilineTextGridItem();
     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
     virtual BOOL OnDrawItemValue(CDC& dc, CRect rcValue);
};

The implementation is short too


CMultilineTextGridItem::CMultilineTextGridItem(CString strCaption, LPCTSTR strValue, CString* pBindString)
:CXTPPropertyGridItem(strCaption, strValue, pBindString)
{
    // do nothing
}

CMultilineTextGridItem::~CMultilineTextGridItem()
{
    // do nothing
}

void CMultilineTextGridItem::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
    CXTPPropertyGridView* pGrid = GetGrid();
    CDC * dc = pGrid->GetDC();
    CRect rc;
    dc->DrawText(GetValue(), &rc, DT_CALCRECT );
    pGrid->ReleaseDC(dc);
    lpMeasureItemStruct->itemHeight = rc.Height();
}

BOOL CMultilineTextGridItem::OnDrawItemValue(CDC& dc, CRect rcValue)
{
    CRect rcText(rcValue);
    dc.DrawText( GetValue(), rcText, DT_LEFT);
    return TRUE;
}

I hope that helps someone else too; feel free to let me know of any bugs.

Colin

 



Posted By: SuperMario
Date Posted: 20 June 2005 at 4:32pm
In the next release (9.70), you can set the size of individual items, multi-line text support is also added


Posted By: CGrant
Date Posted: 20 June 2005 at 5:35pm

Wonderful. Is there somewhere that states the release dates?

 



Posted By: SuperMario
Date Posted: 21 June 2005 at 6:33am
No, But I am really sure it will be by the end of next week


Posted By: gshawn
Date Posted: 21 June 2005 at 10:29am

Originally posted by SuperMario SuperMario wrote:

In the next release (9.70), you can set the size of individual items, multi-line text support is also added

 

That's good news... Will this enhancement also be available in the ActiveX version of the control? Thanks.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net