View previous topic :: View next topic |
Author |
Message |
medbiller
Joined: 20 Dec 2007 Posts: 39 Location: Arroyo, PR
|
Posted: Sun Jul 01, 2012 7:02 pm Post subject: VirtualTree alternating rows back color |
|
|
I have a vTree bound to a 2 table (parent/child) dataset. I used the GetCellData event to set different back colors for odd & even rows. It works beautifully when the vTree is collapse (child table not showing). When the vTree is fully expanded the parent table's alternating rows color pattern is messed up, specially when scrolling with the mouse. Some rows have the odd style & others the even style but in a non alternating fashion. How can I make it so that the alternating pattern for rows in level 1 (parent) is preserved between the collapsed and espanded states? Thanks. _________________ Medical billing & records developer. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jul 02, 2012 12:24 am Post subject: |
|
|
What version of Virtual Tree are you using?
How are you setting the odd/even styles (can you post the code that is doing this)?
If you look at the Data Set Browser sample you will see that it uses different odd/even background styles without the issues you mention - so I suspect the issue may be how you are coding it. In particular note that you should create a separate style object for even and odd rows - not just change the background color of the default style - see the following FAQ for more detail:
http://www.infralution.com/phpBB2/viewtopic.php?t=419 _________________ Infralution Support |
|
Back to top |
|
|
medbiller
Joined: 20 Dec 2007 Posts: 39 Location: Arroyo, PR
|
Posted: Thu Jul 05, 2012 1:53 pm Post subject: |
|
|
Hi, I'm using VTree 4.1.2.0 Here's my code:
Private Sub vtHL7In_GetCellData(sender As Object, e As Infralution.Controls.VirtualTree.GetCellDataEventArgs) Handles vtHL7In.GetCellData
Dim binding As RowBinding = vtHL7In.GetRowBinding(e.Row) 'if this first three lines are not here the tree shows up empty
If binding IsNot Nothing AndAlso e.Row.Level > 0 Then
binding.GetCellData(e.Row, e.Column, e.CellData) 'get the default binding for the given row and use it to populate the cell data
If e.Row.Item("posted").ToString.Trim = "0" Then ''show row colors of not posted messages @ level 1
oddCellStyle.BackColor = notPostedMsgRowColor 'change background color on new style
If chkViewErrs.Checked Then 'vTree is expanded executeing .RootRow.ExpandChildren(True) in chkViewErrs.CheckedChanged event
evenCellStyle.BackColor = notPostedMsgRowColor 'this is to keep all level 1 rows color the same when the tree is expanded showing level 2 rows
Else
evenCellStyle.BackColor = ControlPaint.LightLight(notPostedMsgRowColor) 'to show a subtle difference between adjacent rows when vTree is collapsed
End If
Else 'show row colors of posted messages @ level 1
oddCellStyle.BackColor = postedMsgRowColor 'change background color on new style
If chkViewErrs.Checked Then 'vTree is expanded executeing .RootRow.ExpandChildren(True) in chkViewErrs.CheckedChanged event
evenCellStyle.BackColor = postedMsgRowColor 'this is to keep all level 1 rows color the same when the tree is expanded showing level 2 rows
Else
evenCellStyle.BackColor = ControlPaint.LightLight(postedMsgRowColor) 'to show a subtle difference between adjacent rows
End If
End If
e.CellData.OddStyle = oddCellStyle 'apply new style to this cell; if you just change back color (like e.CellData.OddStyle.BackColor = Color.???) every cell changes to this color because this is a default cell style
e.CellData.EvenStyle = evenCellStyle
End If _________________ Medical billing & records developer. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Jul 05, 2012 10:28 pm Post subject: |
|
|
You should set the BackColor property of the styles inside the GetCellData method. If you change this then it changes the BackColor of all the cells that are using that style.
Instead you should setup the required required styles externally in your form constructor (after InitializeComponent) and then in GetCellData just assign e.CellData.OddStyle and EvenStyle to the appropriate style. _________________ Infralution Support |
|
Back to top |
|
|
medbiller
Joined: 20 Dec 2007 Posts: 39 Location: Arroyo, PR
|
Posted: Fri Jul 06, 2012 12:54 am Post subject: |
|
|
Thanks. I just added vTree.UpdateRowData() after vTree.RootRow.ExpandChildren(True) or vTree.RootRow.CollapseChildren(True) and it seems to work.
On another subject, the following lines of code were causing a NullException randomly and sporaneously and not in every client computer. Also not reproducible. This one was veru difficult to catch:
With vtPayFiles
.FindRow(crw).Item("caseBalanceAft") = ""
.FindRow(crw).Item("caseBalOverUnder") = "3"
End With
Had to change it to:
vtPayFiles.FindRow(crw).Item("caseBalanceAft") = ""
vtPayFiles.FindRow(crw).Item("caseBalOverUnder") = "3"
Is this a bug? _________________ Medical billing & records developer. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Jul 06, 2012 8:13 am Post subject: |
|
|
The only difference in that code is the With statement - is that right?
I can't see the with statement having any affect on the code. More likely there is some condition in your code in which FindRow(crw) returns nothing (ie the row couldn't be found) or else the row was found but your call to your Item("..") method is returning Nothing. You should probably add in some protective code checking for both of these possible conditions. _________________ Infralution Support |
|
Back to top |
|
|
medbiller
Joined: 20 Dec 2007 Posts: 39 Location: Arroyo, PR
|
Posted: Fri Jul 06, 2012 12:07 pm Post subject: |
|
|
Thanks. I can assure that we just took away the With..End With and the problem went away. It has not happened in over 3 months. The fact that it happened so sporaneously an only in some clients with hugh databases made it extremely difficult to find. _________________ Medical billing & records developer. |
|
Back to top |
|
|
|