class ReportItemCheck : public CXTPReportRecordItem
{
public:
ReportItemCheck(BOOL bCheck) {
HasCheckbox(TRUE);
SetChecked(bCheck);
}
virtual int GetGroupCaptionID(CXTPReportColumn* pColumn) {
return IsChecked()? 0: 1;
}
virtual int Compare(CXTPReportColumn* pColumn, CXTPReportRecordItem* pItem) {
return int(IsChecked()) - int(pItem->IsChecked());
}
};
class myReportRow : public CXTPReportGroupRow {
public:
myReportRow() : CXTPReportGroupRow() { }
virtual ~myReportRow() { }
virtual int GetHeight(CDC* pDC) {
return m_nIndex * 20 + 10;
}
};
class myReportCtrl : public CXTPReportControl {
public:
myReportCtrl() : CXTPReportControl() { }
virtual ~myReportCtrl() { }
int InsertRow(int nIndex, CXTPReportRow* pRow) {
return CXTPReportControl::InsertRow(nIndex, pRow);
}
};
//////////////////////////////////////////////////////////// ////////////
/// Somewhere in OnInitDialog
//////////////////////////////////////////////////////////// ////////////
{
...
...
...
reportCtrl = new myReportCtrl();
reportCtrl->Create(WS_CHILD|WS_TABSTOP|WS_VISIBLE|W M_VSCROLL|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_TABSTOP, CRect(0, 0, 400, 250), this, 0);
reportCtrl->GetReportHeader()->AllowColumnRemove (FALSE);
CXTPReportColumn* nameColumn = new CXTPReportColumn(0, TEXT("Name"), 250, TRUE, XTP_REPORT_NOICON, FALSE);
reportCtrl->AddColumn(nameColumn);
CXTPReportColumn* checkColumn = new CXTPReportColumn(1, TEXT("Check"), 18, FALSE, XTP_REPORT_NOICON, FALSE);
reportCtrl->AddColumn(checkColumn);
myReportRow* row;
CXTPReportRecord* record;
CXTPReportRecord* record1;
CXTPReportRecordItem* item;
record = new CXTPReportRecord();
record->AddItem(new CXTPReportRecordItemText(TEXT("John")));
record->AddItem(new ReportItemCheck(true));
row = new myReportRow();
row->InitRow(reportCtrl, record);
reportCtrl->InsertRow(0, row);
record = new CXTPReportRecord();
record->AddItem(new CXTPReportRecordItemText(TEXT("Joe")));
record->AddItem(new ReportItemCheck(false));
row = new myReportRow();
row->InitRow(reportCtrl, record);
reportCtrl->InsertRow(1, row);
record1 = new CXTPReportRecord();
record1->AddItem(new CXTPReportRecordItemText(TEXT("Jason (Joe's son)")));
record1->AddItem(new ReportItemCheck(true));
row = new myReportRow();
row->InitRow(reportCtrl, record1);
record->GetChilds()->Add(record1);
reportCtrl->InsertRow(2, row);
// At This Point I can see that 'rows' is filled with
// the rows I have inserted, but nothing to show yet!!
CXTPReportRows* rows = reportCtrl->GetRows();
reportCtrl->GetColumns()->Find(0)->SetTreeCol umn(TRUE);
reportCtrl->Populate();
...
...
...
}