Reuse a conditional formattings between gridviews

3 posts, 0 answers
  1. Martin Gartmann
    Martin Gartmann avatar
    51 posts
    Member since:
    Apr 2004

    Posted 12 Nov 2015 Link to this post

    Dear members,

    i have 3 grids on 3 forms, but just one gridview  is directly visible for the end user, because the other forms are on seperate monitors away from the pc users view.

    What i want is, that a condtional rules that is defined for the main grid will be copied to the both others.

    Is this supported and if not can i bind for example the rowbackcolor to a my.settings.value?

    i have used

    Dim obj = New ConditionalFormattingObject("MyCondition", ConditionTypes.Startswtih, "1 -", "", True)
    obj.CellForeColor = Color.Red
    obj.RowBackColor = my.settings.fcDIV1
    Me.RadGridView1.Columns("Name").ConditionalFormattingObjectList.Add(obj)​

    but i have gotten a null reference exception.

    Kind regards

    Martin

  2. Martin Gartmann
    Martin Gartmann avatar
    51 posts
    Member since:
    Apr 2004

    Posted 12 Nov 2015 in reply to Martin Gartmann Link to this post

    I have solved my issue on a different way. I use the following snippet:

    Private Sub rgcCurrentTurn_RowFormatting(sender As Object, e As RowFormattingEventArgs) Handles rgcCurrentTurn.RowFormatting
        If Mid(e.RowElement.RowInfo.Cells("Name").Value, 1, 1) = "1" Then
            e.RowElement.DrawFill = True
            e.RowElement.GradientStyle = GradientStyles.Solid
            e.RowElement.BackColor = My.Settings.fcDIV1
        ElseIf Mid(e.RowElement.RowInfo.Cells("Name").Value, 1, 1) = "2" Then
            e.RowElement.DrawFill = True
            e.RowElement.GradientStyle = GradientStyles.Solid
            e.RowElement.BackColor = My.Settings.fcDiv2
        ElseIf Mid(e.RowElement.RowInfo.Cells("Name").Value, 1, 1) = "3" Then
            e.RowElement.DrawFill = True
            e.RowElement.GradientStyle = GradientStyles.Solid
            e.RowElement.BackColor = My.Settings.fcDIV3
        Else
            e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
            e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
            e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
        End If
    End Sub

    You can see the result in the attached image. Want i wanted to archive was, based on the beginning character of  a cell value, to let different weight classes in motorsports, wo are driving in  a combined race (DIV1, DIV2, DIV3) easier to be indentified by the watcers on track.

     This snippet can be reused for all 3 gridviews and the background color is set with the application settings.

    Kind regards

     Martin

     

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 16 Nov 2015 Link to this post

    Hi Martin,

    Thank you for writing.

    I am glad that you have found a solution which fits your scenario. More information about the cell and row formatting API is available here: CellFormatting, RowFormatting, Conditional formatting cells and rows

    I also tested the desired functionality with conditional formatting objects reading the back color value from the application settings. I could not reproduce the NullReferenceException, in case you would like us to further investigate this scenario please isolate the issue in a separate project. Since project attachments are not allowed in forum threads you would need to open a support ticket. I am also sending you my test project which you can use as a template.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top