Version

DeallocateCells Method (UltraGridRow)

Releases allocated cell objects. Cells are allocated lazily as they are accessed. This method is for releasing cells that have been allocated so for.
Syntax
'Declaration
 
Public Sub DeallocateCells() 
public void DeallocateCells()
Remarks

Cells are lazily allocated. They are allocated as they are accessed. However once a cell is allocated, it remains referenced until the row is removed. You can use this method to release references to the cells that have been allocated. Note that they will be re-allocated when they are accessed next time.

One use for this method is to reset all the cells to their default settings. For example, if you have set some settings on the cells of a row and you want to clear all those settings then you can use this method to simply clear the cell collection. This will have the same effect as having reset all the cells of the row with one added benefit that the references to the cells will have been released and thus may result in improved memory usage. Note that the cells will be re-allocated when they are accessed the next time. This method is exposed on the RowsCollection as well so this operation can be performed on an entire row collection as well.

Note: If one of the cells of this row is the current active cell or is selected then it will not be cleared from the collection as the ActiveCell property of the grid (or the SelectedCellsCollection in the case of selected cells) is holding reference to the cell. Such cells will not be cleared. They will remain part of the cell collection. However their settings will be reset. In other words, the end result will be the same.

Note that any references to the cells from this row after ClearCells call should be considered invalid (except for the active cell and selected cells as noted above). Also the cell collection itself is released, which is also lazily allocated.

Example
Following code shows how HasCell and DeallocateCells methods work.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
        Dim row As UltraGridRow = Me.ultraGrid1.Rows(4)
        Dim column As UltraGridColumn = row.Band.Columns("CustomerID")

        ' UltraGrid lazily allocates cells as they are accessed.
        ' If the cell hasn't been accessed yet, HasCell will return false.
        Debug.WriteLine("Cell Allocated? " & row.HasCell(column))

        ' Accessing the cell will cause the UltraGrid to allocate it.
        Dim cell As UltraGridCell = row.Cells(column)

        ' Since we accessed the cell above causing it be allocated, HasCell
        ' will return true.
        Debug.WriteLine("Cell Allocated? " & row.HasCell(column))

        ' You can cause the grid to release references to cells by calling
        ' DeallocateCells. This also means that any cell specific settings
        ' will be cleared.
        row.DeallocateCells()

        ' HasCell will return false since we've de-allocated cells.
        Debug.WriteLine("Cell Allocated? " & row.HasCell(column))
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		private void button1_Click(object sender, System.EventArgs e)
		{
			UltraGridRow row = this.ultraGrid1.Rows[4];
			UltraGridColumn column = row.Band.Columns[ "CustomerID" ];

			// UltraGrid lazily allocates cells as they are accessed.
			// If the cell hasn't been accessed yet, HasCell will return false.
			Debug.WriteLine( "Cell Allocated? " + row.HasCell( column ) );

			// Accessing the cell will cause the UltraGrid to allocate it.
			UltraGridCell cell = row.Cells[ column ];

			// Since we accessed the cell above causing it be allocated, HasCell
			// will return true.
			Debug.WriteLine( "Cell Allocated? " + row.HasCell( column ) );

			// You can cause the grid to release references to cells by calling
			// DeallocateCells. This also means that any cell specific settings
			// will be cleared.
			row.DeallocateCells( );

			// HasCell will return false since we've de-allocated cells.
			Debug.WriteLine( "Cell Allocated? " + row.HasCell( column ) );
		}
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