Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinDataSource
Imports Infragistics.Win.UltraWinGrid
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.UltraGrid1.DataSource = Me.UltraDataSource1
        ' Set the root band key so we can easily refer to it later in various
        ' event handlers.
        '
        Me.UltraDataSource1.Band.Key = "RootBand"
        ' Add three columns to the root band.
        Me.UltraDataSource1.Band.Columns.Add("ID", GetType(Integer))
        Me.UltraDataSource1.Band.Columns.Add("Col0", GetType(Integer))
        Me.UltraDataSource1.Band.Columns.Add("Col1", GetType(String))
        ' Add a child band to the root band.
        Dim childBand As UltraDataBand = Me.UltraDataSource1.Band.ChildBands.Add("ChildBand")
        ' Add two columns to the child band.
        childBand.Columns.Add("ChildCol0", GetType(Double))
        childBand.Columns.Add("ChildCol1", GetType(DateTime))
        ' Set the count on the root rows collection to 100.
        Me.UltraDataSource1.Rows.SetCount(100)
        ' Set the id on the root rows.
        Dim column As UltraDataColumn = Me.UltraDataSource1.Band.Columns("ID")
        Dim i As Integer
        For i = 0 To Me.UltraDataSource1.Rows.Count - 1
            Me.UltraDataSource1.Rows(i)(column) = i
        Next
    End Sub
    Dim random As Random = New Random()
    Private Sub UltraDataSource1_CellDataRequested(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinDataSource.CellDataRequestedEventArgs) Handles UltraDataSource1.CellDataRequested
        ' CellDataRequested is fired for every cell. In CellDataRequested event handler
        '
        ' e.Row property indicates which row and e.Column indicates which column the
        ' cell data is being requested for.
        Dim row As UltraDataRow = e.Row
        If "RootBand" Is e.Column.Band.Key Then
            Select Case e.Column.Key
                Case "Col0"
                    e.Data = Me.random.Next()
                Case "Col1"
                    e.Data = "String " & Me.random.Next()
            End Select
        ElseIf "ChildBand" Is e.Column.Band.Key Then
            Select Case e.Column.Key
                Case "ChildCol0"
                    e.Data = Me.random.NextDouble()
                Case "ChildCol1"
                    e.Data = DateTime.Now.AddDays(Me.random.Next(1000))
            End Select
        End If
        ' If CacheData is set to true, which it is by default, then UltraDataSource
        ' will cache the provided cell value and won't fire CellDataRequested next
        ' time for the cell.
        e.CacheData = True
    End Sub
    Private Sub UltraDataSource1_InitializeRowsCollection(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinDataSource.InitializeRowsCollectionEventArgs) Handles UltraDataSource1.InitializeRowsCollection
        If "ChildBand" Is e.Rows.Band.Key Then
            ' For every parent row, we will have 10 child rows.
            e.Rows.SetCount(10)
        End If
    End Sub