[SOLVED] Using BeforeDrawRow with a TreeColum
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=16687
Printed Date: 21 December 2024 at 8:56pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: [SOLVED] Using BeforeDrawRow with a TreeColum
Posted By: Xander75
Subject: [SOLVED] Using BeforeDrawRow with a TreeColum
Date Posted: 10 May 2010 at 10:13am
Hi,
I am using the ReportControl to display data in a TreeColumn style, as many of the columns display negative numbers I have added the "BeforeDrawRow" event which is as follows:
Private Sub rpcGrid_BeforeDrawRow(Index As Integer, ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics) If Item.Index > 0 Then If IsNumeric(Item.Value) Then Item.ForeColor = IIf(CDbl(Item.Value) < 0, vbRed, vbBlack) End If rpcGrid(Index).Redraw End Sub
This works for the Rows being displayed by default, but once you expand the Tree column by clicking on the plus icon the grid does not update the colours. I did notice however that the grid updates once the row has been expanded and I click on the grid, this seems to update the colours or by moving the mouse over the grid column headers. But I need this to display the colours when the rows are expanded by default.
Is there a better method for forcing a refresh of the ReportControl after using the "BeforeDrawRow" event.
------------- Product: Xtreme SuitePro (ActiveX) v15.3.1 Platform: Windows 7 64-bit (SP1) Professional Edition Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
|
Replies:
Posted By: Aaron
Date Posted: 10 May 2010 at 11:11am
Hi,
I would expect update whenever RC needs to be updated (mouseclicks, scrolling etc. etc.) So expanding means you clicked in RC area and RC will fire BeforeDrawRow events for every single (visible) row.
You can try this:
- Use .Caption instead of .Value in BeforeDrawRow event
- In RowExpanded event add Me.rpcGrid.Redraw
- Use Metrics object to change visual effects *
* Note: You have to change Metrics parameter to have immediate effect. Changing "Item" and "Row" parameters will take effect only on next redraw.
If this doesn't work for you: Is it possible to create test project or show code what you did?
------------- 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: Xander75
Date Posted: 11 May 2010 at 2:52am
Hi Aaron,
Thanks for the quick response, I did try the .Caption but this didn't help.
I had seen that the BeforeDrawRow fires before the row is made visible, therefore I changed the code to use the following DrawItem event as this fires after the rows are made visible:
Private Sub rpcGrid_DrawItem(Index As Integer, 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)
If Item.Index > 0 Then
If IsNumeric(Item.Value) Then Item.ForeColor = IIf(CDbl(Item.Value)
< 0, vbRed, vbBlack) End If End Sub
Private Sub rpcGrid_RowExpanded(Index As Integer, ByVal Row As XtremeReportControl.IReportRow) rpcGrid(Index).Redraw End Sub
This still doesn't cause the ReportControl to update the colours.
I did however try the following, which is a bit messy but works...
Private Sub rpcGrid_RowExpanded(Index As Integer, ByVal Row As XtremeReportControl.IReportRow)
LockWindowUpdate Me.hWnd rpcGrid(Index).ShowHeader = False DoEvents rpcGrid(Index).ShowHeader = True LockWindowUpdate 0&
End Sub
The above code made the ReportControl update correctly, however it is like I said... a bit messy!
|
Posted By: Aaron
Date Posted: 11 May 2010 at 2:22pm
Hi,
You are right about the code you added (it's messy ) If you just change code in BeforeDrawRow event, color will be immediately updated if you expand row.
Private Sub rpcGrid_BeforeDrawRow(Index As Integer, ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics) If Item.Index > 0 Then If IsNumeric(Item.Value) Then Metrics.ForeColor = IIf(CDbl(Item.Value) < 0, vbRed, vbBlack) End If rpcGrid(Index).Redraw End Sub
As I said before: Metrics object will be updated immediately and "Item" and "Row" parameters will take effect only on next redraw.
------------- 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: Xander75
Date Posted: 12 May 2010 at 3:16am
Cheers Aaron...
I must admit that I never understood what you had meant about using the Metrics.
The addition of Metrics has enabled the colour to change immediately, however I have removed the redraw as this was causing the grid to slow down its response time immensely and is no longer required.
Private Sub rpcGrid_BeforeDrawRow(Index As Integer, ByVal Row
As XtremeReportControl.IReportRow, ByVal Item As
XtremeReportControl.IReportRecordItem, ByVal Metrics
As XtremeReportControl.IReportRecordItemMetrics)
If Item.Index > 0 Then
If IsNumeric(Item.Value) Then Metrics.ForeColor
= IIf(CDbl(Item.Value) < 0, vbRed,
vbBlack) End If
rpcGrid(Index).Redraw End Sub
Thanks, this issue is now resolved!
|
Posted By: Aaron
Date Posted: 13 May 2010 at 4:45am
Hi,
Of course you are right about removing .Redraw method, I just copied your code and changed Item.ForeColor into Metrics.ForeColor and didn't remove .Redraw
Metrics object is using copy of row/record/item collection and is able to update values immediately without changing original values. This is nice for just changing visual effects in ReportControl. Well, glad to solve your problem without the "messy code"
------------- 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: Xander75
Date Posted: 13 May 2010 at 5:01am
Yeah finding out about the use of the Metrics object has been a definite help as I had always wondered how to change an individual column colour also.
As for the messy code, this was only there in the interim as I would not have been happy to let that stay!!! lol
Thanks again.
|
|