Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Create a data table with 3 columns. Dim dt As DataTable = New DataTable("Table1") dt.Columns.Add("Col1", GetType(String)) dt.Columns.Add("Col2", GetType(String)) dt.Columns.Add("Col3", GetType(String)) ' Fill the data table with some random data. Dim i As Integer For i = 0 To 100 - 1 dt.Rows.Add(New String() {"Test" & i + 1, "Test" & i + 2, "Test" & i + 3}) Next ' Set the grid's data source to the data table. Me.UltraGrid1.DataSource = dt Dim band As UltraGridBand = Me.UltraGrid1.DisplayLayout.Bands("Table1") ' Get the columns of Table1 band in the UltraGrid. Dim gridColumns As ColumnsCollection = band.Columns ' Turn on the row layout functionality for Table1 band. band.RowLayoutStyle = RowLayoutStyle.ColumnLayout ' Setup the row-layout. ' OriginX OriginY SpanX SpanY gridColumns("Col1").RowLayoutColumnInfo.Initialize(0, 0, 1, 1) gridColumns("Col2").RowLayoutColumnInfo.Initialize(1, 0, 1, 1) gridColumns("Col3").RowLayoutColumnInfo.Initialize(0, 1, 2, 1) ' Allow for multiline text in the Col3 cells. gridColumns("Col3").RowLayoutColumnInfo.Column.CellMultiLine = DefaultableBoolean.True ' Assign a non-zero positive WeightX to Col1 so that any extra ' horizontal space is distributed to that column. For example, ' AutoFitColumns is turned on and the width of the grid is ' bigger than what's required to fit all the columns, extra ' space will be assigned to this column. gridColumns("Col1").RowLayoutColumnInfo.WeightX = 1.0F ' Assign a non-zero positive WeightY to Col3 so that any extra ' vertical space is distribute to that column. For example, ' if the row height is set to a height bigger than what's ' required to fit all columns then extra space is assigned to ' this column. gridColumns("Col3").RowLayoutColumnInfo.WeightY = 1.0F ' Set the default row height to 200 and turn on the auto-fit ' columns to demonstrate the effect that WeightX and WeightY ' properties have. Me.UltraGrid1.DisplayLayout.Override.DefaultRowHeight = 100 Me.UltraGrid1.DisplayLayout.AutoFitColumns = True band.Override.RowSpacingAfter = 5 End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private void Form1_Load(object sender, System.EventArgs e) { // Create a data table with 3 columns. DataTable dt = new DataTable( "Table1" ); dt.Columns.Add( "Col1", typeof( string ) ); dt.Columns.Add( "Col2", typeof( string ) ); dt.Columns.Add( "Col3", typeof( string ) ); // Fill the data table with some random data. for ( int i = 0; i < 100; i++ ) dt.Rows.Add( new string[] { "Test" + i + 1, "Test" + i + 2, "Test" + i + 3 } ); // Set the grid's data source to the data table. this.ultraGrid1.DataSource = dt; UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands["Table1"]; // Get the columns of Table1 band in the UltraGrid. ColumnsCollection gridColumns = band.Columns; // Turn on the row layout functionality for Table1 band. band.RowLayoutStyle = RowLayoutStyle.ColumnLayout; // Setup the row-layout. // OriginX OriginY SpanX SpanY gridColumns["Col1"].RowLayoutColumnInfo.Initialize( 0, 0, 1, 1 ); gridColumns["Col2"].RowLayoutColumnInfo.Initialize( 1, 0, 1, 1 ); gridColumns["Col3"].RowLayoutColumnInfo.Initialize( 0, 1, 2, 1 ); // Allow for multiline text in the Col3 cells. gridColumns["Col3"].RowLayoutColumnInfo.Column.CellMultiLine = DefaultableBoolean.True; // Assign a non-zero positive WeightX to Col1 so that any extra // horizontal space is distributed to that column. For example, // AutoFitColumns is turned on and the width of the grid is // bigger than what's required to fit all the columns, extra // space will be assigned to this column. gridColumns["Col1"].RowLayoutColumnInfo.WeightX = 1.0f; // Assign a non-zero positive WeightY to Col3 so that any extra // vertical space is distribute to that column. For example, // if the row height is set to a height bigger than what's // required to fit all columns then extra space is assigned to // this column. gridColumns["Col3"].RowLayoutColumnInfo.WeightY = 1.0f; // Set the default row height to 200 and turn on the auto-fit // columns to demonstrate the effect that WeightX and WeightY // properties have. this.ultraGrid1.DisplayLayout.Override.DefaultRowHeight = 100; this.ultraGrid1.DisplayLayout.AutoFitColumns = true; band.Override.RowSpacingAfter = 5; }