Print Page | Close Window

ReportControl item with checkbox

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=1912
Printed Date: 07 November 2025 at 2:39pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: ReportControl item with checkbox
Posted By: Arnie
Subject: ReportControl item with checkbox
Date 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 ?

 




Replies:
Posted By: sserge
Date 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


Posted By: Arnie
Date 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;"

 

 


 




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