This is a migrated thread and some comments may be shown as answers.

RowFormatting going crazy

3 Answers 90 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 2
Veteran
Marco asked on 10 Jul 2012, 08:35 AM
Hello,

I want to give a different format to some rows (based on a property of the databound items). It works good, but some rows decide, on they own, to use a special format.

If I use only one BackColor and a solid GradientStyle, the problem do not appear (but linear Gradient looks far better. Isn't it?)

Should I have miss something or it's bug ?

Private Sub dgv_Clients_RowFormatting(sender As System.Object, e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles dgv_Clients.RowFormatting

Dim ClientBound As Client = TryCast(e.RowElement.Data.DataBoundItem, Client)
If ClientBound IsNot Nothing AndAlso Helper.ActiveDirectoryHelper.GetInstance.GetCurrentUser.Guid.Equals(ClientBound.FK_OwnerUser) Then
e.RowElement.DrawFill = True
e.RowElement.BackColor = Color.Red
e.RowElement.BackColor2 = Color.White
e.RowElement.BackColor3 = Color.White
e.RowElement.BackColor4 = Color.White
e.RowElement.GradientStyle = GradientStyles.Linear
e.RowElement.GradientAngle = 360
Else
e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
e.RowElement.ResetValue(LightVisualElement.BackColor2Property, ValueResetFlags.Local)
e.RowElement.ResetValue(LightVisualElement.BackColor3Property, ValueResetFlags.Local)
e.RowElement.ResetValue(LightVisualElement.BackColor4Property, ValueResetFlags.Local)
e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
e.RowElement.ResetValue(LightVisualElement.GradientAngleProperty, ValueResetFlags.Local)
End If
End Sub

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 12 Jul 2012, 02:17 PM
Hi Marco,

Thank you for writing.

I do not see an obvious reason in the code for the behavior you are experiencing. I would suggest a slight modification to your code which might make things better. Here is it:
Private Sub dgv_Clients_RowFormatting(sender As System.Object, e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles dgv_Clients.RowFormatting
 
  Dim ClientBound As Client = TryCast(e.RowElement.Data.DataBoundItem, Client)
  If ClientBound IsNot Nothing AndAlso Helper.ActiveDirectoryHelper.GetInstance.GetCurrentUser.Guid.Equals(ClientBound.FK_OwnerUser) Then
    e.RowElement.DrawFill = True
    e.RowElement.BackColor = Color.Red
    e.RowElement.BackColor2 = Color.White
    e.RowElement.NumberOfColors = 2
    e.RowElement.GradientStyle = GradientStyles.Linear
    e.RowElement.GradientAngle = 360
  Else
    e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
    e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
    e.RowElement.ResetValue(LightVisualElement.BackColor2Property, ValueResetFlags.Local)
    e.RowElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local)
    e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
    e.RowElement.ResetValue(LightVisualElement.GradientAngleProperty, ValueResetFlags.Local)
  End If
End Sub
This will make the element to always use two colors for the gradient.

 If this does not solve your problem, I would kindly ask you to send me your project or a sample where you reproduce this issue so I can investigate it and give you an accurate response.

Looking forward to your reply.
 
Greetings,
Ivan Petrov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Marco
Top achievements
Rank 2
Veteran
answered on 12 Jul 2012, 02:24 PM
Hi Ivan, 

Thank you for the NumberOfColors Tip.

I will test this solution as soon as possible and come back here for the result.
0
Marco
Top achievements
Rank 2
Veteran
answered on 16 Jul 2012, 07:34 AM
Hi Ivan,

Giving a value to the number of colors property has fix the strange behavior of the row format.

Thank you again !
Tags
GridView
Asked by
Marco
Top achievements
Rank 2
Veteran
Answers by
Ivan Petrov
Telerik team
Marco
Top achievements
Rank 2
Veteran
Share this question
or