int CMergeView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CXTPReportView::OnCreate(lpCreateStruct) == -1) return -1;
CXTPReportControl& wndReport = GetReportCtrl(); wndReport.GetPaintManager()->SetGridStyle(TRUE, xtpReportGridSolid); wndReport.ShowGroupBy(FALSE); wndReport.ShowHeaderRows(TRUE);
int nColumnCount = 7; int nHeaderCount = 2; int nRecordCount = 10; int nColumn; int nRecord;
CXTPReportRecord *pRecord = NULL; for (nColumn=0; nColumn<nColumnCount; nColumn++) { CXTPReportColumn *pColumn = new CXTPReportColumn(nColumn, _T(""), 90, TRUE); pColumn = wndReport.AddColumn(pColumn); }
// Add header records for (nRecord=0; nRecord<nHeaderCount; nRecord++) { pRecord = wndReport.GetHeaderRecords()->Add(new CXTPReportRecord()); for (nColumn=0; nColumn<nColumnCount; nColumn++) { CXTPReportRecordItemText *pItem = new CXTPReportRecordItemText(); pItem->SetBackgroundColor(RGB(223,227,232)); pItem->SetAlignment(xtpColumnTextCenter|xtpColumnTextVCenter); pRecord->AddItem(pItem); } }
// Create multiline header wndReport.HeaderRowsAllowSort(FALSE); wndReport.HeaderRowsAllowGroup(FALSE); wndReport.HeaderRowsAllowAccess(FALSE); pRecord = wndReport.GetHeaderRecords()->GetAt(0); pRecord->GetItem(0)->SetCaption(_T("1")); pRecord->GetItem(3)->SetCaption(_T("Vehicle Id")); pRecord->GetItem(5)->SetCaption(_T("Last multiline column header"));
pRecord = wndReport.GetHeaderRecords()->GetAt(1); pRecord->GetItem(0)->SetCaption(_T("First")); pRecord->GetItem(1)->SetCaption(_T("Second")); pRecord->GetItem(2)->SetCaption(_T("Third")); pRecord->GetItem(3)->SetCaption(_T("Fourth")); pRecord->GetItem(4)->SetCaption(_T("Fifth")); #if _XTPLIB_VERSION_PREFIX >= 1511 wndReport.GetHeaderRecords()->MergeItems(CXTPReportRecordItemRange(0,2,0,0)); wndReport.GetHeaderRecords()->MergeItems(CXTPReportRecordItemRange(3,4,0,0)); wndReport.GetHeaderRecords()->MergeItems(CXTPReportRecordItemRange(5,6,0,1)); #endif
// Add records for (nRecord=0; nRecord<nRecordCount; nRecord++) { pRecord = wndReport.AddRecord(new CXTPReportRecord()); for (nColumn=0; nColumn<nColumnCount; nColumn++) { CString sText; sText.Format(_T("Row %d, %d"), nRecord, nColumn);
CXTPReportRecordItemText *pItem = new CXTPReportRecordItemText(sText); pRecord->AddItem(pItem); } } wndReport.Populate(); wndReport.SetFocus();
return 0; } |