Back to Devexpress

ColumnView.BeginSort() Method

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-423f5690.md

latest3.0 KB
Original Source

ColumnView.BeginSort() Method

Prevents visual and internal data updates until the ColumnView.EndSort method is called.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public void BeginSort()
vb
Public Sub BeginSort

Remarks

This method is equivalent to the ColumnView.BeginDataUpdate method. See this topic to learn more.

Example

The code sample below iterates through grid records and reduces the “Price” column values by 10 percent.

csharp
private void UpdatePrice(DevExpress.XtraGrid.Views.Base.ColumnView View) {
   // Obtain the Price column. 
   DevExpress.XtraGrid.Columns.GridColumn col = View.Columns.ColumnByFieldName("Price");
   if (col == null) return;
   View.BeginSort();
   try {
      // Obtain the number of data rows. 
      int dataRowCount = View.DataRowCount;
      // Traverse data rows and change the Price field values. 
      for (int i = 0; i < dataRowCount; i++) {
         object cellValue = View.GetRowCellValue(i, col);
         double newValue = Convert.ToDouble(cellValue) * 0.9;
         View.SetRowCellValue(i, col, newValue);
      }
   } finally { View.EndSort(); }
}
vb
Private Sub UpdatePrice(ByVal View As DevExpress.XtraGrid.Views.Base.ColumnView)
   ' Obtain the Price column. 
   Dim Col As DevExpress.XtraGrid.Columns.GridColumn = View.Columns.ColumnByFieldName("Price")
   If Col Is Nothing Then Exit Sub 
   View.BeginSort()
   Try 
      ' Obtain the number of data rows. 
      Dim DataRowCount As Integer = View.DataRowCount
      ' Traverse data rows and change the Price field values. 
      Dim I As Integer 
      For I = 0 To DataRowCount - 1
         Dim CellValue As Object = View.GetRowCellValue(I, Col)
         Dim NewValue As Double = Convert.ToDouble(CellValue) * 0.9
         View.SetRowCellValue(I, Col, NewValue)
      Next 
   Finally 
      View.EndSort()
   End Try 
End Sub

See Also

BeginDataUpdate()

Batch Modifications

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace