バージョン

PreferredCellSize プロパティ

最適セル サイズ。デフォルト値は Size(0,0) です。これは、適度なデフォルト サイズが計算されることを意味します。
シンタックス
'宣言
 
Public Property PreferredCellSize As Size
public Size PreferredCellSize {get; set;}
解説

PreferredCellSize の Width が 0 に設定される場合、UltraGridColumn.Width の値は幅として使用されます。Height が 0 に設定されている場合は、適度なデフォルトの高さが計算されます。

複数のセルの OriginX と SpanX が同じで(垂直に積み上げられており)、PreferredCellSize の設定が異なる場合、そのようなセルはすべて最大の幅で表示されます。同様に、複数のセルの OriginY と SpanY が同じで(水平に並んでおり)、PreferredCellSize の設定が異なる場合、そのようなセルはすべて最大の高さで表示されます。

MinimumCellSize プロパティが 0 より大きい幅のサイズに設定されている場合は、MinimumCellSize の幅と PreferredCellSize の幅のうち、大きい方がセルのサイズとして使用されます。同じことが高さにも適用されます。

使用例
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
        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))
        dt.Columns.Add("Col4", GetType(String))
        dt.Columns.Add("Col5", GetType(String))

        Dim random As Random = New Random()
        Dim i As Integer
        For i = 0 To 100 - 1
            Dim rowdata(4) As String
            Dim j As Integer
            For j = 0 To 5 - 1
                rowdata(j) = random.Next(1000).ToString()
            Next
            dt.Rows.Add(rowdata)
        Next

        Me.UltraGrid1.DataSource = dt

        ' Get the columns of Table1 band in the UltraGrid.
        Dim gridColumns As ColumnsCollection = Me.UltraGrid1.DisplayLayout.Bands("Table1").Columns

        ' Turn on the row layout functionality for Table1 band.
        Me.UltraGrid1.DisplayLayout.Bands("Table1").RowLayoutStyle = RowLayoutStyle.ColumnLayout

        ' Allow the user to only resize width of the columns/labels.
        Me.UltraGrid1.DisplayLayout.Bands("Table1").Override.AllowRowLayoutCellSizing = RowLayoutSizing.Horizontal
        Me.UltraGrid1.DisplayLayout.Bands("Table1").Override.AllowRowLayoutLabelSizing = RowLayoutSizing.Horizontal

        ' Setup Col1 column.
        gridColumns("Col1").RowLayoutColumnInfo.OriginX = 0
        gridColumns("Col1").RowLayoutColumnInfo.OriginY = 0
        gridColumns("Col1").RowLayoutColumnInfo.SpanX = 1
        gridColumns("Col1").RowLayoutColumnInfo.SpanY = 1
        ' Set the preferred cell size to 200,0 so that it's at least 200 pixel wide.
        ' Height of 0 means that the UltraGrid will calculate one based on the font.
        gridColumns("Col1").RowLayoutColumnInfo.PreferredCellSize = New Size(200, 0)
        ' Set the MinimumCellSize to 50,0 to prevent the user from resizing the column
        ' and making it smaller than 50 in width.
        gridColumns("Col1").RowLayoutColumnInfo.MinimumCellSize = New Size(50, 0)

        ' Setup Col2 column.
        gridColumns("Col2").RowLayoutColumnInfo.OriginX = 1
        gridColumns("Col2").RowLayoutColumnInfo.OriginY = 0
        gridColumns("Col2").RowLayoutColumnInfo.SpanX = 1
        gridColumns("Col2").RowLayoutColumnInfo.SpanY = 1

        ' Setup Col3 column.
        gridColumns("Col3").RowLayoutColumnInfo.OriginX = 0
        gridColumns("Col3").RowLayoutColumnInfo.OriginY = 1
        gridColumns("Col3").RowLayoutColumnInfo.SpanX = 1
        gridColumns("Col3").RowLayoutColumnInfo.SpanY = 1

        ' Setup Col4 column.
        gridColumns("Col4").RowLayoutColumnInfo.OriginX = 1
        gridColumns("Col4").RowLayoutColumnInfo.OriginY = 1
        gridColumns("Col4").RowLayoutColumnInfo.SpanX = 1
        gridColumns("Col4").RowLayoutColumnInfo.SpanY = 1
        ' Set the preferred cell size to 150,0 so that it's at least 150 pixel wide.
        ' Height of 0 means that the UltraGrid will calculate one based on the font.
        gridColumns("Col4").RowLayoutColumnInfo.PreferredCellSize = New Size(150, 0)
        ' Set the MinimumCellSize to 50,0 to prevent the user from resizing the column
        ' and making it smaller than 50 in width.
        gridColumns("Col4").RowLayoutColumnInfo.MinimumCellSize = New Size(60, 0)

        ' Setup Col5 column.
        gridColumns("Col5").RowLayoutColumnInfo.OriginX = 0
        gridColumns("Col5").RowLayoutColumnInfo.OriginY = 2
        ' Set the SpanX to Remainder so that it occupies the rest of the horizontal space.
        gridColumns("Col5").RowLayoutColumnInfo.SpanX = RowLayoutColumnInfo.Remainder
        gridColumns("Col5").RowLayoutColumnInfo.SpanY = 1
        ' Set the preferred cell size height to 40.
        gridColumns("Col5").RowLayoutColumnInfo.PreferredCellSize = New Size(0, 40)
        gridColumns("Col5").CellMultiLine = DefaultableBoolean.True
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

		private void Form1_Load(object sender, System.EventArgs e)
		{
			DataTable dt = new DataTable( "Table1" );
			dt.Columns.Add( "Col1", typeof( string ) );
			dt.Columns.Add( "Col2", typeof( string ) );
			dt.Columns.Add( "Col3", typeof( string ) );
			dt.Columns.Add( "Col4", typeof( string ) );
			dt.Columns.Add( "Col5", typeof( string ) );

			Random random = new Random( );
			for ( int i = 0; i < 100; i++ )
			{
				string[] rowData = new string[ 5 ];
				for ( int j = 0; j < 5; j++ )
					rowData[j] = random.Next( 1000 ).ToString( );
				
				dt.Rows.Add( rowData );
			}

			this.ultraGrid1.DataSource = dt;

			// Get the columns of Table1 band in the UltraGrid.
			ColumnsCollection gridColumns = this.ultraGrid1.DisplayLayout.Bands["Table1"].Columns;

			// Turn on the row layout functionality for Table1 band.
			this.ultraGrid1.DisplayLayout.Bands["Table1"].RowLayoutStyle = RowLayoutStyle.ColumnLayout;

			// Allow the user to only resize width of the columns/labels.
			this.ultraGrid1.DisplayLayout.Bands["Table1"].Override.AllowRowLayoutCellSizing  = RowLayoutSizing.Horizontal;
			this.ultraGrid1.DisplayLayout.Bands["Table1"].Override.AllowRowLayoutLabelSizing = RowLayoutSizing.Horizontal;

			// Setup Col1 column.
			gridColumns["Col1"].RowLayoutColumnInfo.OriginX = 0;
			gridColumns["Col1"].RowLayoutColumnInfo.OriginY = 0;
			gridColumns["Col1"].RowLayoutColumnInfo.SpanX   = 1;
			gridColumns["Col1"].RowLayoutColumnInfo.SpanY   = 1;
			// Set the preferred cell size to 200,0 so that it's at least 200 pixel wide.
			// Height of 0 means that the UltraGrid will calculate one based on the font.
			gridColumns["Col1"].RowLayoutColumnInfo.PreferredCellSize = new Size( 200, 0 );
			// Set the MinimumCellSize to 50,0 to prevent the user from resizing the column
			// and making it smaller than 50 in width.
			gridColumns["Col1"].RowLayoutColumnInfo.MinimumCellSize = new Size( 50, 0 );

			// Setup Col2 column.
			gridColumns["Col2"].RowLayoutColumnInfo.OriginX = 1;
			gridColumns["Col2"].RowLayoutColumnInfo.OriginY = 0;
			gridColumns["Col2"].RowLayoutColumnInfo.SpanX   = 1;
			gridColumns["Col2"].RowLayoutColumnInfo.SpanY   = 1;
		
			// Setup Col3 column.
			gridColumns["Col3"].RowLayoutColumnInfo.OriginX = 0;
			gridColumns["Col3"].RowLayoutColumnInfo.OriginY = 1;
			gridColumns["Col3"].RowLayoutColumnInfo.SpanX   = 1;
			gridColumns["Col3"].RowLayoutColumnInfo.SpanY   = 1;
		
			// Setup Col4 column.
			gridColumns["Col4"].RowLayoutColumnInfo.OriginX = 1;
			gridColumns["Col4"].RowLayoutColumnInfo.OriginY = 1;
			gridColumns["Col4"].RowLayoutColumnInfo.SpanX   = 1;
			gridColumns["Col4"].RowLayoutColumnInfo.SpanY   = 1;
			// Set the preferred cell size to 150,0 so that it's at least 150 pixel wide.
			// Height of 0 means that the UltraGrid will calculate one based on the font.
			gridColumns["Col4"].RowLayoutColumnInfo.PreferredCellSize = new Size( 150, 0 );
			// Set the MinimumCellSize to 50,0 to prevent the user from resizing the column
			// and making it smaller than 50 in width.
			gridColumns["Col4"].RowLayoutColumnInfo.MinimumCellSize = new Size( 60, 0 );
		
			// Setup Col5 column.
			gridColumns["Col5"].RowLayoutColumnInfo.OriginX = 0;
			gridColumns["Col5"].RowLayoutColumnInfo.OriginY = 2;
			// Set the SpanX to Remainder so that it occupies the rest of the horizontal space.
			gridColumns["Col5"].RowLayoutColumnInfo.SpanX   = RowLayoutColumnInfo.Remainder;
			gridColumns["Col5"].RowLayoutColumnInfo.SpanY   = 1;
			// Set the preferred cell size height to 40.
			gridColumns["Col5"].RowLayoutColumnInfo.PreferredCellSize = new Size( 0, 40);
			gridColumns["Col5"].CellMultiLine = DefaultableBoolean.True;
		}
参照