I want to change the colour of rows in grid based on the flag value in a field. I have atleast 300 000 rows! this means that the following is not going to do the trick.
for a = 0 to UltraGrid.Rows.Count - 1
if Ultragrid.ActiveRow.Cells("Flag_Done").Value = "True"
Ultragrid.ActiveRow.Appearance.BackColor = Color.LightGreen
else
Ultragrid.ActiveRow.Appearance.BackColor = Color.white
endif
next
How can a pre-paint the rows. The above takes to long, VERY slow
Hi Marius,
I am just checking about the progress of this issue. Let me know if you need my further assistance on this issue.
Thank you for using Infragistics Components.
Thank you for the response.
What you could use for this is the ActiveRowAppearance property. This way when the user clicks the row it will become the active row and it will use its ActiveAppearance. When the user selects the next row it will use the normal appearance based on the flag’s value. You can set the active appearance using code like:
ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.BackColor = Color.Blue
Please let me know if you have any additional questions.
Hi , this is working fine... here is my code below. THe problem is: When I click on the Row in grid, the background colour changes, and when I leave that row to the next row, it should return to the original colour. (Unless the operator changed the Flag)
How can I do this.. I want to be able to remember the colour before the row was selected, and return to that colour when the row is left....
If CallerTask1 = True Then
Dim Followup As String = e.Row.GetCellValue("Followup").ToString
Dim Complete As String = e.Row.GetCellValue("Complete").ToString
Dim Noanswer As String = e.Row.GetCellValue("Noanswer").ToString
Dim Callerhangup As String = e.Row.GetCellValue("CallerHangup").ToString
Dim WrongNumber As String = e.Row.GetCellValue("WrongNumber").ToString
Dim CallBackPlease As String = e.Row.GetCellValue("CallBackPlease").ToString
If Followup = "T" Then
Dim Kleur As Color = chkFollowUP.BackColor
e.Row.Appearance.BackColor = Kleur
End If
If Complete = "T" Then
Dim kleur As Color = chkCallSuccesful.BackColor
e.Row.Appearance.BackColor = kleur
If Noanswer = "T" Then
Dim kleur As Color = chkNoAnswer.BackColor
If Callerhangup = "T" Then
Dim kleur As Color = chkCallerHangUp.BackColor
If WrongNumber = "T" Then
Dim kleur As Color = chkWrongNumber.BackColor
If CallBackPlease = "T" Then
Dim kleur As Color = chkCallBackLater.BackColor
End Sub
Thank you for contacting Infragistics Developer Support.
What you could do if you want to change the row color based on some value is to use the InitializeRow event. The event passes you the row and you can examine the values of any cell in that row. Based on those values, you can set the Appearance on the row or any cell in that row. To do this you can use code like:
If CBool(e.Row.GetCellValue(e.Row.Band.Columns("Flag_Done"))) Then e.Row.Appearance = flagDoneApp Else e.Row.Appearance = flagDoneApp End If
e.Row.Appearance = flagDoneApp
Else
Also please note that it’s better if you re-use the appearance objects and not set them directly. For more information please visit this link:
http://help.infragistics.com/Doc/WinForms/2013.2/CLR4.0/?page=WinGrid_Memory_Usage.html
I am looking forward to your reply.