Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - ReportControl item with checkbox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ReportControl item with checkbox

 Post Reply Post Reply
Author
Message
Arnie View Drop Down
Newbie
Newbie


Joined: 04 March 2005
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arnie Quote  Post ReplyReply Direct Link To This Post Topic: ReportControl item with checkbox
    Posted: 04 March 2005 at 8:40am

Hi,

Here is part of a class that i would like to use for records in a report control that displays items with checkboxes:

class CRecordPropertyCheck : public CXTPReportRecord
{
protected:
class CMessageRecordItemCheck : public CXTPReportRecordItem
{
public:
CMessageRecordItemCheck(BOOL bCheck)
{
  HasCheckbox(TRUE);
  SetChecked(bCheck);
}

virtual
void OnClick(XTP_REPORTRECORDITEM_CLICKARGS* pClickArgs)
{
  CXTPReportRecordItem::OnClick(pClickArgs);
  SetCaption(IsChecked() ? "Yes":"No");
}
...

The caption is not set correctly this way.
Is OnClick the right place to change the caption when the user clicks the checkbox ?

 

Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 04 March 2005 at 10:08am
Hi Arnie,

Instead of using SetCaption you should override GetCaption method inside your class, for example:

virtual CString GetCaption()
{
     return IsChecked() ? "Yes":"No";
}

And inside OnClick method you should only change your internal class state and call control redraw to update the view:

virtual void OnClick(XTP_REPORTRECORDITEM_CLICKARGS* pClickArgs)
{
     if (...) // any your conditions
     {
           SetChecked(!IsChecked());
           pClickArgs->pControl->RedrawControl();
     }
     CXTPReportRecordItem::OnClick( pClickArgs);
}

--
Best regards,
Sergey
Back to Top
Arnie View Drop Down
Newbie
Newbie


Joined: 04 March 2005
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arnie Quote  Post ReplyReply Direct Link To This Post Posted: 07 March 2005 at 6:00am

Thanks Sergey,

I got it to work with one change to your code.  I had to remove SetChecked(!IsChecked());

Must be because m_bChecked is set by
CXTPReportRecordItem::OnClick :
"m_bChecked = !m_bChecked;"

 

 


 

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.047 seconds.