Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - [SOLVED] Using BeforeDrawRow with a TreeColum
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED] Using BeforeDrawRow with a TreeColum

 Post Reply Post Reply
Author
Message
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED] Using BeforeDrawRow with a TreeColum
    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)
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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:
 
  1. Use .Caption instead of .Value in BeforeDrawRow event
  2. In RowExpanded event add Me.rpcGrid.Redraw
  3. 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....
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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.
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.