Print Page | Close Window

Limit text of CXTPPropertyGridItem

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=3221
Printed Date: 16 November 2024 at 9:53am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Limit text of CXTPPropertyGridItem
Posted By: Martin
Subject: Limit text of CXTPPropertyGridItem
Date Posted: 15 November 2005 at 4:24am

Hello,

I think I have a simple question but I just cannot find the solution to it.

I want to restrict the text length of a CXTPPropertyGridItem.

This is what I've tried with no luck:

CXTPPropertyGridItem *pItem = pCategory->AddChildItem(new CXTPPropertyGridItem("Description"));

CXTPPropertyGridInplaceEdit *pEdit = &pItem->GetInplaceEdit();
pEdit->SetLimitText(10);

But this didn't work....

I also tried using a mask and that works but I am wondering if there's a better solution, I don't want to use the mask for this unless I have no choice.

Ideas anyone?

TIA,

Martin




Replies:
Posted By: Vitaly
Date Posted: 23 November 2005 at 7:13am

Trying do the same now, and also stuck there. Have you found a solution yet?

 



Posted By: Martin
Date Posted: 23 November 2005 at 7:15am

Nope....

still stuck



Posted By: Vitaly
Date Posted: 23 November 2005 at 11:40am

I found it!!! It appears you just need to override class CXTPPropertyGridItem like i did for my UserField entity:

class CUserFieldEdit:public CXTPPropertyGridInplaceEdit

{

public:

 

      CUserFieldEdit():m_iMaxChars(0){};

 

      void SetMaxChars(int iMaxChars)

      {

             m_iMaxChars = iMaxChars;

      }

 

protected:

 

      virtual void Create(CXTPPropertyGridItem * pItem, CRect rect)

      {

             __super::Create(pItem, rect);

            

             if(m_iMaxChars)                               // If limit was defined;

                   SetLimitText(m_iMaxChars);    // Set the limit;

      }

 

private:

 

      int m_iMaxChars;

};

 

class CUserFieldItem:public CXTPPropertyGridItem

{

public:

      CUserFieldItem(LPCTSTR strItem, int iMaxChars):CXTPPropertyGridItem(strItem)

      {

             m_edit.SetMaxChars(iMaxChars);

      }

 

protected:

 

      virtual CXTPPropertyGridInplaceEdit & GetInplaceEdit()

      {

             return m_edit;

      }

 

private:

 

      CUserFieldEdit m_edit;

};

Then instead of

CXTPPropertyGridItem * pItem   = m_UFGrid.AddCategory(_T(""));

pItem->AddChildItem(new CXTPPropertyGridItem(_T("User Field 1")));

you'll be calling:

CXTPPropertyGridItem * pItem   = m_UFGrid.AddCategory(_T(""));

pItem->AddChildItem(new CUserFieldItem(_T("User Field 1"), 10));

 



Posted By: Martin
Date Posted: 24 November 2005 at 1:35am

Great, thank you!

This is one way to do it, but I was hoping for a more easier, obvious solution. 

Hopefully the CJ team is willing to implement this into a next release!

Cheers!




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