Highlight Selected Report Columns |
Post Reply |
Author | |
eam74
Groupie Joined: 18 June 2014 Location: USA Status: Offline Points: 15 |
Post Options
Thanks(0)
Posted: 18 June 2014 at 11:30am |
Hi all,
I am working on a report control for my application and have a couple features that I haven't been able to find a solution for yet: 1. When a user clicks on an item, highlight the corresponding column. If you sort, the column will be highlighted, but in my control the sort must be disabled, so there is no highlight. 2. Allow the user to select multiple columns. I know this is possible because the report sample allows this, but I can't figure out where this option is set, unless this also is a consequence of disabling sorting. 3. (would be nice, but not critical) Remove the selection box around the row and customize the background color. I am able to turn off highlighting for the row with wndReport.SelectionEnable(FALSE) but the box still shows up. I found an old forum topic which suggests the function to override is GetItemMetrics, which I did, but it's not getting called - where exactly should this be added? TIA |
|
Xtreme ToolkitPro (C++) v16.1.0, Windows 7
|
|
eam74
Groupie Joined: 18 June 2014 Location: USA Status: Offline Points: 15 |
Post Options
Thanks(0)
|
Updates!
1. Based on the MessageRecord class in ReportSample, I created a custom record class which overrides GetItemMetrics. This works to alter the colors of the currently selected row, but no others. It appears to be calling this function for all rows so I don't know why it only changes colors for the selected row. Code: void CCustomRecord::GetItemMetrics(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pItemMetrics) { if (pDrawArgs->pColumn->GetIndex() == 3) { // hard-coded temporarily pDrawArgs->pControl->GetPaintManager()->m_clrHighlight = RGB(140, 240, 255); pDrawArgs->pControl->GetPaintManager()->m_clrHighlightText = RGB(0,0,0); } else if (pDrawArgs->pRow->IsSelected()) { pDrawArgs->pControl->GetPaintManager()->m_clrHighlight = RGB(240, 140, 255); pDrawArgs->pControl->GetPaintManager()->m_clrHighlightText = RGB(0,0,0); } } 3. reportCtrl.ShowRowFocus(FALSE); |
|
Xtreme ToolkitPro (C++) v16.1.0, Windows 7
|
|
eam74
Groupie Joined: 18 June 2014 Location: USA Status: Offline Points: 15 |
Post Options
Thanks(0)
|
Further update on item #1:
Able to paint a particular column using a custom CXTPReportPaintManager that overrides DrawColumnBackground, as such: void CCustomReportPaintManager::DrawColumnBackground(CDC* pDC, CXTPReportColumn* pColumn, CRect rcColumn, BOOL& bColumnPressed, BOOL& bDraggingFromHeader, CXTPReportHeader* pHeader) { if (pColumn->GetIndex()==1){ // column CXTPReportRecords* rows = pColumn->GetControl()->GetRecords(); int i; for (i=0; i < rows->GetCount(); i++) { CXTPReportRecord* r = pColumn->GetControl()->GetRecords()->GetAt(i); r->GetItem(pColumn)->SetBackgroundColor(RGB(140, 240, 255)); } pColumn->SetAlignment(xtpColumnTextRight); } else { pColumn->SetAlignment(xtpColumnTextCenter); } } Still some work left in tracking which is the currently selected column, and haven't found anything for item #2, but hopefully this is of use to someone searching in the future :) |
|
Xtreme ToolkitPro (C++) v16.1.0, Windows 7
|
|
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 |