Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - [Solved]Prevent from column to displayed as select
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[Solved]Prevent from column to displayed as select

 Post Reply Post Reply
Author
Message
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Topic: [Solved]Prevent from column to displayed as select
    Posted: 11 May 2015 at 5:40pm
One of the column is state and has background color according to a state (Red, Orange, Yellow, and Green). When a row selected the selected color override the entire row including the state column. How I can prevent the state column to get the select color?

I would like that the state column remain its original background when the row selected.

Regards.

Yoav


Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2015 at 5:46am
CXTPReportControl::SelectionEnable(FALSE)  for disable selection at all.

OR  If you want remain background only for SOME columns you should change  CXTPReportRow::GetItemMetrics() method. Just  move this line to the end of method
   m_pControl->GetItemMetrics(pDrawArgs, pItemMetrics);

Then you can set background color and other metrics through  XTP_NM_REPORT_GETITEMMETRICS  event. Choose needed recordItems by  pItemNotify->pDrawArgs->pColumn

BEGIN_MESSAGE_MAP(CReportSampleView, CXTPReportView)
ON_NOTIFY(XTP_NM_REPORT_GETITEMMETRICS, XTP_ID_REPORT_CONTROL, OnReportGetItemMetrics)
END_MESSAGE_MAP()

void CReportSampleView::OnReportGetItemMetrics(NMHDR* pNotifyStruct, LRESULT* /*result*/)
{
XTP_NM_REPORTITEMMETRICS* pItemNotify = (XTP_NM_REPORTITEMMETRICS*)pNotifyStruct;

ASSERT(pItemNotify->pDrawArgs);
ASSERT(pItemNotify->pDrawArgs->pControl);
ASSERT(pItemNotify->pDrawArgs->pRow);

// pItemNotify->pDrawArgs->pColumn - may be NULL (for a group row)
// pItemNotify->pDrawArgs->pItem - may be NULL (for a group row)

ASSERT(pItemNotify->pItemMetrics);

// TODO: customize members of pItemNotify->pItemMetrics.

CXTPReportColumn* pColumn = pItemNotify->pDrawArgs->pColumn;
if ( IsStateColumn(pColumn) )
pItemNotify->pItemMetrics->clrBackground = GetBackColorForStateColumn(pColumn);
}

Back to Top
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2015 at 11:41am
Solved the problem.
Thanks.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2015 at 3:49pm
yoavm, How exactly?
Back to Top
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (1) Thanks(1)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2015 at 6:25pm

By the second option.

I changed CXTPReportRow::GetItemMetrics() method and added OnReportGetItemMetrics. Currently I can set the background and foreground colors of the State column when it selected.
Very nice solution.
 
Yoav
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.