Version

Add(String,Type) Method

Adds a new column with the specified key and specified data type.
Syntax
'Declaration
 
Public Overloads Function Add( _
   ByVal columnKey As String, _
   ByVal dataType As Type _
) As UltraDataColumn
public UltraDataColumn Add( 
   string columnKey,
   Type dataType
)

Parameters

columnKey
Key of the new column.
dataType
Column's data type.

Return Value

Returns the new column.
Example
Following code shows how to setup an UltraDataSource with some columns and rows. It creates a hiearchical data source with two bands.

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

        ' Add two columns to the root band.
        Me.UltraDataSource1.Band.Columns.Add("Col0", GetType(String))
        Me.UltraDataSource1.Band.Columns.Add("Col1", GetType(String))

        ' Add a child band to the root band with the key of "ChildBand".
        Dim childBand As UltraDataBand = Me.UltraDataSource1.Band.ChildBands.Add("ChildBand")

        ' Add two columns to the child band.
        childBand.Columns.Add("ChildCol0", GetType(String))
        childBand.Columns.Add("ChildCol1", GetType(String))

        ' Set the count on the root rows collection to 2.
        Me.UltraDataSource1.Rows.SetCount(2)

        Dim row As UltraDataRow

        ' Initialize rows with data.

        'Get the first row.
        row = Me.UltraDataSource1.Rows(0)
        row("Col0") = "Row 0, Col 0"
        row("Col1") = "Row 0, Col 1"

        ' Initialize the child rows of the row.
        Dim childRows As UltraDataRowsCollection = row.GetChildRows("ChildBand")
        childRows.SetCount(2)
        childRows(0)("ChildCol0") = "Child Row 0, ChildCol 0"
        childRows(0)("ChildCol1") = "Child Row 0, ChildCol 1"

        childRows(1)("ChildCol0") = "Child Row 1, ChildCol 0"
        childRows(1)("ChildCol1") = "Child Row 1, ChildCol 1"

        ' Get the second row.
        row = Me.UltraDataSource1.Rows(1)
        row("Col0") = "Row 1, Col 0"
        row("Col1") = "Row 1, Col 1"

        ' Initialize the child rows of the row.
        childRows = row.GetChildRows("ChildBand")
        childRows.SetCount(1)
    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;

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

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

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

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

			UltraDataRow row;

			// Initialize rows with data.

			//Get the first row.
			row = this.ultraDataSource1.Rows[0];
			row[ "Col0" ] = "Row 0, Col 0";
			row[ "Col1" ] = "Row 0, Col 1";

			// Initialize the child rows of the row.
			UltraDataRowsCollection childRows = row.GetChildRows( "ChildBand" );
			childRows.SetCount( 2 );
			childRows[0][ "ChildCol0" ] = "Child Row 0, ChildCol 0";
			childRows[0][ "ChildCol1" ] = "Child Row 0, ChildCol 1";

			childRows[1][ "ChildCol0" ] = "Child Row 1, ChildCol 0";
			childRows[1][ "ChildCol1" ] = "Child Row 1, ChildCol 1";

			// Get the second row.
			row = this.ultraDataSource1.Rows[1];
			row[ "Col0" ] = "Row 1, Col 0";
			row[ "Col1" ] = "Row 1, Col 1";

			// Initialize the child rows of the row.
			childRows = row.GetChildRows( "ChildBand" );
            childRows.SetCount( 1 );
		}
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