Version

AutoSizeEdit Property

Determines if the column will allow auto-expanding pop-up edit windows.
Syntax
'Declaration
 
Public Property AutoSizeEdit As Infragistics.Win.DefaultableBoolean
public Infragistics.Win.DefaultableBoolean AutoSizeEdit {get; set;}
Remarks

One of the features the UltraWinGrid offers is the ability to expand a cell when it is in edit mode to provide a greater area for the user to enter data. This is controlled by the AutoSizeEdit property. When set to True, text editing for any cell takes place in a pop-up window that expands to accommodate the amount of text being entered. When the user shifts the input focus away, the edit window disappears and the cell is shown normally.

The attributes of the pop-up edit window are determined by the properties of the CancelableAutoSizeEditEventArgs object. Available properties let you specify the starting and maximum height and width of the pop-up window. This object is available only inside of the UltraGrid.BeforeAutoSizeEdit event, where it is accessed via the e object of the event.

Example
Following code enables auto-size edit feature of the UltraGrid and shows you how to control some aspects of it using BeforeAutoSizeEdit event.

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.UltraWinGrid

  Private Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button6.Click

      ' Following code enables auto-size-edit feature on the Address column.
      ' It also makes the column multiline.

      Me.ultraGrid1.DisplayLayout.Bands(0).Columns("Address").AutoSizeEdit = DefaultableBoolean.True
      Me.ultraGrid1.DisplayLayout.Bands(0).Columns("Address").CellMultiLine = DefaultableBoolean.True

  End Sub

  Private Sub UltraGrid1_BeforeAutoSizeEdit(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableAutoSizeEditEventArgs) Handles ultraGrid1.BeforeAutoSizeEdit

      ' BeforeAutoSizeEdit gets fired when a cell in a column with AutoSizeEdit set to True
      ' is going into edit mode.

      ' Set the start width of the edit control. This is the width the edit control in the 
      ' cell will start out with.
      If Me.ultraGrid1.ActiveCell.Column.Width < 250 Then
          e.StartWidth = 250
      End If

      If Me.ultraGrid1.ActiveCell.Column.CellMultiLine = DefaultableBoolean.True And Me.ultraGrid1.ActiveCell.Row.Height < 100 Then
          e.StartHeight = 100
      End If

      ' Set the max width and height. The UltraGrid will not resize the edit control
      ' larger than max height and max width.
      e.MaxHeight = 400
      e.MaxWidth = 400

      ' One can cancel auto-size-edit in which case the cell will do regular editing.
      Dim cancelAutoSizeEdit As Boolean = False
      If cancelAutoSizeEdit Then e.Cancel = True

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void button6_Click(object sender, System.EventArgs e)
{

	// Following code enables auto-size-edit feature on the Address column.
	// It also makes the column multiline.

	this.ultraGrid1.DisplayLayout.Bands[0].Columns["Address"].AutoSizeEdit  = DefaultableBoolean.True;
	this.ultraGrid1.DisplayLayout.Bands[0].Columns["Address"].CellMultiLine = DefaultableBoolean.True;

}

private void ultraGrid1_BeforeAutoSizeEdit(object sender, Infragistics.Win.UltraWinGrid.CancelableAutoSizeEditEventArgs e)
{

	// BeforeAutoSizeEdit gets fired when a cell in a column with AutoSizeEdit set to True
	// is going into edit mode.

	// Set the start width of the edit control. This is the width the edit control in the 
	// cell will start out with.
	if ( this.ultraGrid1.ActiveCell.Column.Width < 250 )
		e.StartWidth = 250;

	if ( this.ultraGrid1.ActiveCell.Column.CellMultiLine == DefaultableBoolean.True &&
		this.ultraGrid1.ActiveCell.Row.Height < 100 )
		e.StartHeight = 100;

	// Set the max width and height. The UltraGrid will not resize the edit control
	// larger than max height and max width.
	e.MaxHeight = 400;
	e.MaxWidth = 400;

	// One can cancel auto-size-edit in which case the cell will do regular editing.
	bool cancelAutoSizeEdit = false;
	if ( cancelAutoSizeEdit )
		e.Cancel = true;

}
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