[SOLVED] Using BeforeDrawRow with a TreeColum |
Post Reply |
Author | |
Xander75
Senior Member Joined: 26 April 2007 Status: Offline Points: 353 |
Post Options
Thanks(0)
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) |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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:
* 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.... |
|
Xander75
Senior Member Joined: 26 April 2007 Status: Offline Points: 353 |
Post Options
Thanks(0)
|
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! |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Xander75
Senior Member Joined: 26 April 2007 Status: Offline Points: 353 |
Post Options
Thanks(0)
|
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 End Sub Thanks, this issue is now resolved! |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Xander75
Senior Member Joined: 26 April 2007 Status: Offline Points: 353 |
Post Options
Thanks(0)
|
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. |
|
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 |