RowFormatting and ElementVisibility.Collapsed Problem

2 posts, 0 answers
  1. QuizzBox
    QuizzBox avatar
    93 posts
    Member since:
    Jan 2011

    Posted 21 Nov 2016 Link to this post

    Hello everybody,

    I have a problem using the element visibilty property on ElementVisibility.Collapsed on the radgridview RowFormatting event.

    When i try to put the row visibility to ElementVisibility.Collapsed, there is a strange behavior, the rows are not correctly displayed.

    Here is a sample that reproduces the problem :

    Imports Telerik.WinControls.UI
     
    Public Class RadForm1
        Private _Liste As New List(Of MyClass1)
     
        Public Sub New()
     
            ' Cet appel est requis par le concepteur.
            InitializeComponent()
     
            ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
            _Liste.Add(New MyClass1 With {.Prop1 = 10, .Prop2 = "AAA" & .Prop1})
            _Liste.Add(New MyClass1 With {.Prop1 = 10, .Prop2 = "BBB" & .Prop1})
            _Liste.Add(New MyClass1 With {.Prop1 = 10, .Prop2 = "CCC" & .Prop1})
            _Liste.Add(New MyClass1 With {.Prop1 = 100, .Prop2 = "DDD" & .Prop1})
            _Liste.Add(New MyClass1 With {.Prop1 = 100, .Prop2 = "FFF" & .Prop1})
            _Liste.Add(New MyClass1 With {.Prop1 = 1, .Prop2 = "QQQ" & .Prop1})
            _Liste.Add(New MyClass1 With {.Prop1 = 1, .Prop2 = "SSS" & .Prop1})
            RadGridView1.DataSource = _Liste
     
        End Sub
     
        Private Sub RadGridView1_RowFormatting(sender As Object, e As RowFormattingEventArgs) Handles RadGridView1.RowFormatting
            If DirectCast(e.RowElement.RowInfo.DataBoundItem, MyClass1).Prop1 = 10 Then
                e.RowElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            Else
                e.RowElement.Visibility = Telerik.WinControls.ElementVisibility.Visible
            End If
     
        End Sub
     
        Private Class MyClass1
            Public Property Prop1 As Integer
            Public Property Prop2 As String
        End Class
     
    End Class

    Maybe i'm missing something, but when i replace Telerik.WinControls.ElementVisibility.Collapsed by Telerik.WinControls.ElementVisibility.Hidden, i have the expected behavior (except that the rows are not collapsed).

     

    Thanks in advance for your answers, and sorry for my aweful english ... I'm french.

     

    I'm using Windows 7 64 bits, with 2016.3.1024.40 version of radcontrols, and .Net Framework v4

  2. Ralitsa
    Admin
    Ralitsa avatar
    192 posts

    Posted 22 Nov 2016 Link to this post

    Hello Jean-Mark,

    Thank you for contacting us. 

    If I understand correctly, you want to hide few rows, so you can achieve it by setting the RowInfo.IsVisible property to false. Here is the code snippet demonstrating the solution: 
    Private Sub RadGridView1_RowFormatting_1(sender As Object, e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles RadGridView1.RowFormatting
        If DirectCast(e.RowElement.RowInfo.DataBoundItem, MyClass1).Prop1 = 10 Then
            e.RowElement.RowInfo.IsVisible = False
        Else
            e.RowElement.RowInfo.IsVisible = True
        End If
    End Sub

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Ralitsa
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Back to Top