RadGridView supports out-of-the-box binding to sub objects by intuitive and simple dot (.) syntax (specified through the FieldName property of declaratively bound columns). The example below includes a "Person" class that has three properties, one of which is a reference type "Car":

Public Class Person
Public _name As String = ""
Public _city As String = ""
Public _car As Car = Nothing
Public Sub New()
Me._car = New Car()
End Sub
Public Sub New(name As String, city As String, car As Car)
Me._name = name
Me._city = city
Me._car = car
End Sub
Public ReadOnly Property Name() As String
Get
Return Me._name
End Get
End Property
Public ReadOnly Property City() As String
Get
Return Me._city
End Get
End Property
Public ReadOnly Property Car() As Car
Get
Return Me._car
End Get
End Property
End Class
Public Class Car
Private _model As String
Private _year As Integer
Public Sub New()
End Sub
Public Sub New(model As String, year As Integer)
Me._model = model
Me._year = year
End Sub
Public ReadOnly Property Model() As String
Get
Return Me._model
End Get
End Property
Public ReadOnly Property Year() As Integer
Get
Return Me._year
End Get
End Property
End Class

Lets populate a BindingList of Person with some objects and bind it to RadGridView.

Binding RadGridView to Person automatically creates three columns for all properties of the Person object. The value properties are displayed correctly, but the reference property is displayed in "dot" notation (see the third (Car) column in the screenshot below).

Now to setup the sub-property binding of the Car column, all you have to do is to declare in the FieldName property of the column, the name of the Car object property that you want to bind the column to (Model or Year), using the dot notation:

radGridView1.Columns[2].FieldName = "Car.Model";

RadGridView1.Columns(2).FieldName = "Car.Model"

The result is that the Car column is now bound to the Model property of the Car object

Was this article helpful?

/

Give article feedback

Tell us how we can improve this article

Code samples are inaccurate / outdated.
I expected to find other / more information.
There are typos / broken links / broken page elements.
Content is inaccurate / outdated.
Other
By checking this box you consent to Progress contacting you by email about your response on this page.

Community

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.