How to add CMessageRecordItemCheck class? |
Post Reply |
Author | |
Pluto
Newbie Joined: 07 June 2007 Location: United States Status: Offline Points: 4 |
Post Options
Thanks(0)
Posted: 22 September 2009 at 5:14pm |
Hi everyone,
I am struggled this for a few days already. Please help a newbie out. I am trying to add a check box to my ReportControl class.
I've added the following to my class' header:
class CMessageRecordItemCheck : public CXTPReportRecordItem{
DECLARE_SERIAL(CMessageRecordItemCheck) public : // Constructs record item with the initial checkbox value.CMessageRecordItemCheck(BOOL bCheck = FALSE); // Provides custom group captions depending on checkbox value. // Returns caption string ID to be read from application resources. virtual int GetGroupCaptionID(CXTPReportColumn* pColumn); // Provides custom records comparison by this item based on checkbox value, // instead of based on captions. virtual int Compare(CXTPReportColumn* pColumn, CXTPReportRecordItem* pItem);};
I also added the floowing to my class' cpp file:
IMPLEMENT_SERIAL(CMessageRecordItemCheck, CXTPReportRecordItem, VERSIONABLE_SCHEMA | _XTP_SCHEMA_CURRENT) CMessageRecordItemCheck::CMessageRecordItemCheck(BOOL bCheck) { HasCheckbox(TRUE); SetChecked(bCheck); } int CMessageRecordItemCheck::GetGroupCaptionID(CXTPReportColumn* /*pColumn*/){ return IsChecked()? IDS_GROUP_CHECKED_TRUE: IDS_GROUP_CHECKED_FALSE; }int CMessageRecordItemCheck::Compare(CXTPReportColumn* /*pColumn*/, CXTPReportRecordItem* pItem){ return int(IsChecked()) - int(pItem->IsChecked()); }I created the checkbox column by:
pColumn = AddColumn( new CXTPReportColumn(CXTPReportColumn(COLUMN_CHECK, _T(""), 18, FALSE, COLUMN_CHECK_ICON)) );I added the item to the record at the beginning of the record by:
pItem = pRecord->AddItem( new CMessageRecordItemCheck(bChecked));I am able to see the check box icon in the column header but I am not able to see a checkbox in any row. Did I miss anything? Is there a detail tutorial for this somewhere?
Any input is appreciated!
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Please look and analyze MFC ReportSample where CMessageRecord have checkbox item as you can see in this static exe -
|
|
Pluto
Newbie Joined: 07 June 2007 Location: United States Status: Offline Points: 4 |
Post Options
Thanks(0)
|
Thank you! I've checked the samples and I am expecting the similar effects on my code. I just not sure what went wrong. Any hints? What else do I miss?
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
You don't need to create special CMessageRecordItemCheck
Just use usual CXTPReportRecordItem
and call function CXTPReportRecordItem::HasCheckbox(BOOL bHasCheckbox, BOOL bTristate = FALSE)
to setup checkbox if needed and usual or 3-state checkbox type
// Adds check box area for item.
// Parameters:
// bHasCheckbox - TRUE if item has check box area.
// bTristate - TRUE is tri-state checkbox, FALSE - if usual
// See Also: SetChecked, IsChecked
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |