RowFormatting going crazy

4 posts, 1 answers
  1. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 10 Jul 2012 Link to this post

    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

     

  2. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 12 Jul 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 12 Jul 2012 Link to this post

    Hi Ivan, 

    Thank you for the NumberOfColors Tip.

    I will test this solution as soon as possible and come back here for the result.
  5. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 16 Jul 2012 Link to this post

    Hi Ivan,

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

    Thank you again !
Back to Top