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

ListView Detail Data Binding Hide Column

2 Answers 484 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 05 Oct 2012, 08:01 PM
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 Answers, 1 is accepted

Sort by
0
Nick
Top achievements
Rank 1
answered on 05 Oct 2012, 08:10 PM
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.
0
Ivan Todorov
Telerik team
answered on 09 Oct 2012, 01:32 PM
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 >>
Tags
ListView
Asked by
Nick
Top achievements
Rank 1
Answers by
Nick
Top achievements
Rank 1
Ivan Todorov
Telerik team
Share this question
or