Version

RefreshSortPosition Method (UltraGridRow)

If the row is not at correct sort position, this method will reposition the row in the rows collection based on the current sort criteria. Also if it's in the wrong group, it will put it under appropriate group by row.
Syntax
'Declaration
 
Public Overridable Sub RefreshSortPosition() 
public virtual void RefreshSortPosition()
Remarks

This method can be useful in situations where a new row is added to the rows collection (which by default is appended at the end of the collection) and you want to ensure the row is positioned at the right position in the collection based on the sort criteria without having to resort the whole collection. This method should not be used if the sort criteria itself changes which effects the whole rows collection.

To resort all the rows of a band, call SortedColumnsCollection.RefreshSort method of the SortedColumnsCollection object.

Example
Following method shows how RefreshSortPosition works. It sorts rows by the first column and then changes the value of the first row causing the row to be out of sort order. It calls the RefreshSortPosition method to reposition the row in the correct sort order.

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

  Private Sub Button64_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button64.Click

      ' Get a band and a column.
      Dim band As UltraGridBand = Me.ultraGrid1.DisplayLayout.Bands(0)
      Dim column As UltraGridColumn = band.Columns(0)

      ' Sort by that column.
      band.SortedColumns.Clear()
      band.SortedColumns.Add(column, False)

      ' Get a row.
      Dim row As UltraGridRow = Me.ultraGrid1.Rows(0)

      ' Change the value of the cell associated with the column that the rows are
      ' sorted by.
      row.Cells(column).Value = "Sweden"

      ' Get the index before calling the RefreshSortPosition.
      Dim oldIndex As Integer = row.Index

      row.RefreshSortPosition()

      ' Get the index after calling the RefreshSortPosition.
      Dim newIndex As Integer = row.Index

      ' Show a message box with both indexes.
      MessageBox.Show("Index before RefreshSortPosition = " & oldIndex & vbCrLf & _
                      "Index after RefreshSortPosition = " & newIndex)

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

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

	// Get a band and a column.
	UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];
	UltraGridColumn column = band.Columns[0];

	// Sort by that column.
	band.SortedColumns.Clear( );
	band.SortedColumns.Add( column, false );

	// Get a row.
	UltraGridRow row = this.ultraGrid1.Rows[0];

	// Change the value of the cell associated with the column that the rows are
	// sorted by.
	row.Cells[column].Value = "Sweden";

	// Get the index before calling the RefreshSortPosition.
	int oldIndex = row.Index;	

	row.RefreshSortPosition( );

	// Get the index after calling the RefreshSortPosition.
	int newIndex = row.Index;

	// Show a message box with both indexes.
	MessageBox.Show( "Index before RefreshSortPosition = " + oldIndex + 
					"\nIndex after RefreshSortPosition = " + newIndex );

}
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