Print Page | Close Window

Report Control Selection 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=16622
Printed Date: 15 May 2024 at 1:36pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Report Control Selection Color
Posted By: JamGodz
Subject: Report Control Selection Color
Date Posted: 22 April 2010 at 10:00pm
Hi Everyone!

i still can't get it, when i tried to select a row the backcolor and forecolor of an item i set is gone... all i want is to retain the backcolor and forecolor of the item...
im using VB6 and ReportControl 13.2.1


Any help would be greatly appreciated.. tnx





Replies:
Posted By: Baldur
Date Posted: 24 April 2010 at 9:45am
What do you realy mean?
Ich you set the for- and backcolor for an individual item, these colors are reused if an other row is selected.
The selectioncolors are defined in the paintmanager of the reportcontrol.
 
If you don't want to use the selection-colors, you must use ownerdraw and you have to draw each item by yourself.
In this case you overwrite the selectioncolors.
 
But the problem may be, that the user can't see any mor, which row is currently selected.


Posted By: JamGodz
Date Posted: 25 April 2010 at 8:29pm
Hi Baldur, Good Day!

Thank you for your reply. I had set the backcolor=vbred when an item is less  than zero or have a negative value. Then my problem is when the user select the row, the backcolor=vbred which i set earlier had been replace by the highlighted color. all i need is to retain the vbred backcolor to emphasize to user that the selected/highlighted row had contain a negative value. Please refer my code below on how i set an item to vbred. Please i need help on this.


Private Sub wndReportControl_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics)
    If Item.Index >= 1 Then Metrics.ColumnAlignment = xtpAlignmentIconRight Or xtpAlignmentRight
    If Left$(Item.Value, 1) = "-" Then
        Metrics.BackColor = 12632319
        Metrics.Font.Bold = True
        Metrics.ForeColor = vbRed
    End If
    If Row.Selected Then
        If Metrics.BackColor <> 12632319 Then
            Metrics.BackColor = m_HighlightBackcolor
        Else
            Metrics.BackColor = 12632319
        End If
    End If
End Sub

Any suggestion or comment would be greatly appreciated.

Thank you!



Posted By: Baldur
Date Posted: 26 April 2010 at 1:17pm
This doesn't help in BeforeDrawRow, because the selected row will be drawn with the selection colors.
You have to draw the entire row by yourself with windows-gdi-functions.
 
You need the flag xtpCustomDrawItem!
Than, in the DrawItem-Event you can decide, what to do.
 
It's too heavy to explain here how to use GDI-Functions to the given hDC.


Posted By: Aaron
Date Posted: 26 April 2010 at 2:04pm
Hi,
 
If you set wndReportControl.SelectionEnable = False you are still able to see which row has been selected (dotted rectangle) and you are able to select a color for an item in BeforeDrawRow event (the code you already have)
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: tobi
Date Posted: 26 April 2010 at 3:41pm
I'm also looking for a way to make the blue selection bar ( without SelectionEnable = False ) some kind of transparent to see colored cells also when they are selected ...


Posted By: Baldur
Date Posted: 26 April 2010 at 3:57pm
Once more again:
If the selectionbar is enabled (SelectionEnable = True) you have to draw the cells by yourself.
You can use the Windows-Function SetBkColor, SetTextColor and ExtTextOut or DrawText to draw each cell as you want.
In the DrawItem-Event you get all you need.
For examlpe:
 
Public Type cRect
  left As Long
  top As Long
  right As Long
  bottom As Long
End Type
 
Public Declare Function SetBkColor Lib "gdi32" (ByVal hDC As Long, ByVal crColor As Long) As Long
Public Declare Function SetTextColor Lib "gdi32" (ByVal hDC As Long, ByVal crColor As Long) As Long
Public Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal wOptions As Long, lpRect As cRect, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
 
 
Private Sub repReport_DrawItem(ByVal Row As XtremeReportControl.IReportRow, ByVal Column As XtremeReportControl.IReportColumn, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal hDC As stdole.OLE_HANDLE, ByVal left As Long, ByVal top As Long, ByVal right As Long, ByVal bottom As Long, DoDefault As Boolean)
   Dim xTextRect As cRect
   
   xTextRect.left = left + 1               ' Text
   xTextRect.right = right - 2
   xTextRect.top = top + 1
   xTextRect.bottom = bottom - 2
   SetBkColor hDC, Item.Backcolor
   SetTextColor hDC, Item.ForeColor
   ExtTextOut hDC, 0, 0, ETO_OPAQUE, xTextRect, Item.Caption, -1, 0
 
   DoDefault = False
end sub


Posted By: Hemesh
Date Posted: 26 August 2010 at 5:14am
Just tried this sample, can't get the text to show in the first column now, and the selection highlight still appears. Need to play around with this to get an outline working maybe.

Think CJ need a feature to have different selection modes like xtpSold and xtpOutline!

EDIT: Got the outline I wanted by setting SelectionEnable = False and ShowRowFocus = true and not bothering with customdrawing!


-------------
Product: Xtreme SuitePro (ActiveX) version 18.5.0

Platform: Windows 7 Enterprise (64-bit)

Language: Visual Basic 6.0



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