Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Property Grid
  New Posts New Posts RSS Feed - Limit text of CXTPPropertyGridItem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Limit text of CXTPPropertyGridItem

 Post Reply Post Reply
Author
Message
Martin View Drop Down
Newbie
Newbie
Avatar

Joined: 26 April 2005
Location: Netherlands
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Martin Quote  Post ReplyReply Direct Link To This Post Topic: Limit text of CXTPPropertyGridItem
    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

Back to Top
Vitaly View Drop Down
Groupie
Groupie


Joined: 05 November 2004
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Vitaly Quote  Post ReplyReply Direct Link To This Post Posted: 23 November 2005 at 7:13am

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

 

Back to Top
Martin View Drop Down
Newbie
Newbie
Avatar

Joined: 26 April 2005
Location: Netherlands
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Martin Quote  Post ReplyReply Direct Link To This Post Posted: 23 November 2005 at 7:15am

Nope....

still stuck

Back to Top
Vitaly View Drop Down
Groupie
Groupie


Joined: 05 November 2004
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Vitaly Quote  Post ReplyReply Direct Link To This Post 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));

 

Back to Top
Martin View Drop Down
Newbie
Newbie
Avatar

Joined: 26 April 2005
Location: Netherlands
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Martin Quote  Post ReplyReply Direct Link To This Post 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!

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.