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!
|