Print Page | Close Window

Row selction vs. column background color

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=3861
Printed Date: 15 May 2024 at 6:05am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Row selction vs. column background color
Posted By: nighthawk
Subject: Row selction vs. column background color
Date Posted: 24 March 2006 at 5:07am
I have a special column on a table where each record has a different background color for the column.  (Just like the colored flag status column in Outlook.)  When I select a row, the row turns gray to indicate the row is selected but it overwrites the background color on the special column.  Is there any way to specify the column to not turn gray when a row is selected.  I still need the other columns of the row to turn gray though.



Replies:
Posted By: sserge
Date Posted: 24 March 2006 at 8:02am
Try to use GetItemMetrics() callback method. See ReportSample for Automatic Formatting option and CMessageRecord::GetItemMetrics() sample method.

--
WBR,
Serge


Posted By: nighthawk
Date Posted: 27 March 2006 at 9:17am
I tried playing with the metrics but it only effected the non-selected items.  When I select a row, it still turns the entire row gray.


Posted By: sserge
Date Posted: 01 April 2006 at 6:56am
Hi,

Agree with you, selection colors will override any other colors set inside GetItemMetrics(). So far, the solution would be to change control's  PaintManager highlight colors on the moment of drawing this item.

Inside GetItemMetrics(), insert a piece of code like following:

if (pDrawArgs->pRow->IsSelected())
{
    pDrawArgs->pControl->GetPaintManager()->m_clrHighli ght = RGB(245, 245, 245);
    pDrawArgs->pControl->GetPaintManager()->m_clrHighli ghtText = RGB(80, 100, 225);
}
else
{
    pDrawArgs->pControl->GetPaintManager()->m_clrHighli ght = pDrawArgs->pControl->GetPaintManager()->m_clrHighli ght.GetStandardColor();
    pDrawArgs->pControl->GetPaintManager()->m_clrHighli ghtText = pDrawArgs->pControl->GetPaintManager()->m_clrHighli ghtText.GetStandardColor();
}


--
WBR,
Serge


Posted By: nighthawk
Date Posted: 01 April 2006 at 7:07am
How about in VB?


Posted By: sserge
Date Posted: 01 April 2006 at 9:08am
Almost the same. Inside _BeforeDrawRow() event handler:


If Row.Selected Then
    wndReportControl.PaintManager.HighlightBackColor = vbRed
Else
    wndReportControl.PaintManager.HighlightBackColor = -1
End If


--
WBR,
Serge


Posted By: nighthawk
Date Posted: 01 April 2006 at 11:42am
That is very close to what I was looking for but it still changed the highlighted color for the entire row.  I did get it to work with the following modified code:


    If ((Row.Selected = True) And (Item.ToolTip = "Alias Color")) Then
        grdItems.PaintManager.HighlightBackColor = Item.BackColor
        grdItems.PaintManager.HighlightForeColor = Item.ForeColor
    Else
        grdItems.PaintManager.HighlightBackColor = -1
        grdItems.PaintManager.HighlightForeColor = -1
    End If


I was luckily able to use the Item.ToolTip field to identify the specific column that I did not want to be highlighted. 

I would like to suggest adding a property for a ReportColumn object such as "ShowHighlighted" so I could simply do something like:


Column.ShowHighlighted = False


in order to prevent item in that column from changing background and foreground colors when the row is selected.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net