ListView Detail Data Binding Hide Column

3 posts, 0 answers
  1. Nick
    Nick avatar
    2 posts
    Member since:
    Oct 2012

    Posted 05 Oct 2012 Link to this post

    Hello,

    I am experimenting with your controls before we buy them and have a question. I have a class (for sake of demo I have simplified it) that I am binding to a RadListView via a binding list. Can I prevent the Badge column from appearing in the list view? The listview is actually used to display many different types of data so I would prefer a method that did not involve me manually hiding the column.

     Public Class Visitor
            Friend Sub New(name As String, arrival As Date, department As String, badge As Integer)
                _Name = name
                _ArrivalTime = arrival
                _Department = department
                _Badge = badge
            End Sub

            Private _Name As String
            Public ReadOnly Property Name As String
                Get
                    Return _Name
                End Get
            End Property

            Private _ArrivalTime As Date
            Public ReadOnly Property ArrivalTime As Date
                Get
                    Return _ArrivalTime
                End Get
            End Property

            Private _Department As String

            Public ReadOnly Property Department As String
                Get
                    Return _Department
                End Get
            End Property

            Private _Badge As Integer
            Public ReadOnly Property Badge As Integer
                Get
                    Return _Badge
                End Get
            End Property
        End Class

    Thank You.
  2. Nick
    Nick avatar
    2 posts
    Member since:
    Oct 2012

    Posted 05 Oct 2012 Link to this post

    I should note that I do need to bind the badge column in certain circumstances so  <System.ComponentModel.Browsable(False)> does not meet my needs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 09 Oct 2012 Link to this post

    Hi Nick,

    Thank you for contacting us.

    You can handle the ColumnCreating event to set the Visible property of each column you need to hide:
    Private Sub radListView1_ColumnCreating(ByVal sender As Object, ByVal e As ListViewColumnCreatingEventArgs) Handles radListView1.ColumnCreating
                If e.Column.FieldName = "Badge" Then
                    e.Column.Visible = False
                End If
            End Sub

    This is also demonstrated in the First Look example of RadListView in our Examples application so you can refer to it for additional details.

    I hope I was able to help. Do not hesitate to write back if you have any further questions.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top