Version

Key Property (UltraDataBand)

Overridden. The Key of the item in its collection. This proeprty specifies the name of the band.
Syntax
'Declaration
 
Public Overrides Property Key As String
public override string Key {get; set;}
Remarks

The Key of a band is also used as the the list name of the row collection associated with the band. ITypedList's GetListName implementation returns this value. The keys have to be unique across all the bands.

Example
Following sample code demonstrates commonly used properties and events in UltraDataSource object model.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinDataSource;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.ultraGrid1.DataSource = this.ultraDataSource1;

			// Set the root band key so we can easily refer to it later in various
			// event handlers.
			//
			this.ultraDataSource1.Band.Key = "RootBand";

			// Add three columns to the root band.
			this.ultraDataSource1.Band.Columns.Add( "ID", typeof( int ) );
			this.ultraDataSource1.Band.Columns.Add( "Col0", typeof( int ) );
			this.ultraDataSource1.Band.Columns.Add( "Col1", typeof( string ) );

			// Add a child band to the root band.
			UltraDataBand childBand = this.ultraDataSource1.Band.ChildBands.Add( "ChildBand" );

			// Add two columns to the child band.
			childBand.Columns.Add( "ChildCol0", typeof( double ) );
			childBand.Columns.Add( "ChildCol1", typeof( DateTime ) );

			// Set the count on the root rows collection to 100.
			this.ultraDataSource1.Rows.SetCount( 100 );

			// Set the id on the root rows.
			UltraDataColumn column = this.ultraDataSource1.Band.Columns["ID"];
			for ( int i = 0; i < this.ultraDataSource1.Rows.Count; i++ )
				this.ultraDataSource1.Rows[i][column] = i;
		}

		Random random = new Random( );

		private void ultraDataSource1_CellDataRequested(object sender, Infragistics.Win.UltraWinDataSource.CellDataRequestedEventArgs e)
		{
			// CellDataRequested is fired for every cell.

			// e.Row property indicates which row and e.Column indicates which column the
			// cell data is being requested for.
			UltraDataRow row = e.Row;

			if ( "RootBand" == e.Column.Band.Key )
			{
				switch ( e.Column.Key )
				{
					case "Col0":
						e.Data = this.random.Next( );
						break;
					case "Col1":
						e.Data = "String " + this.random.Next( );
						break;
				}
			}
			else if ( "ChildBand" == e.Column.Band.Key )
			{
				switch ( e.Column.Key )
				{
					case "ChildCol0":
						e.Data = this.random.NextDouble( );
						break;
					case "ChildCol1":
						e.Data = DateTime.Now.AddDays( this.random.Next( 1000 ) );
						break;
				}
			}

			// 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;
		}

		private void ultraDataSource1_InitializeRowsCollection(object sender, Infragistics.Win.UltraWinDataSource.InitializeRowsCollectionEventArgs e)
		{
			if ( "ChildBand" == e.Rows.Band.Key )
			{
				// For every parent row, we will have 10 child rows.
				e.Rows.SetCount( 10 );
			}
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also