Imports System.Data.OleDb
Imports Telerik.WinControls.UI

Public Class Form1
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\Nwind.mdb")
        conn.Open()
        Dim cmd As New OleDbCommand("Select TOP 5 * FROM Categories", conn)
        Dim reader As OleDbDataReader = cmd.ExecuteReader()
        RadGridView1.MasterTemplate.LoadFrom(reader)

        Dim cmd1 As New OleDbCommand("Select TOP 5 * FROM Products", conn)
        Dim reader1 As OleDbDataReader = cmd1.ExecuteReader()
        Dim template As New GridViewTemplate()
        template.LoadFrom(reader1)
        RadGridView1.MasterTemplate.Templates.Add(template)

        Dim relation As New GridViewRelation(RadGridView1.MasterTemplate)
        relation.ChildTemplate = template
        relation.RelationName = "OrderNumber"
        relation.ParentColumnNames.Add("CategoryID")
        relation.ChildColumnNames.Add("CategoryID")
        RadGridView1.Relations.Add(relation)

        template.Columns("UnitPrice").FormatString = "{0:C}"

    End Sub
End Class
