Skip to main content
A newer version of this page is available. .

BaseView.DataRowCount Property

Gets how many data rows are contained within the View.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v19.1.dll

Declaration

[Browsable(false)]
public int DataRowCount { get; }

Property Value

Type Description
Int32

An integer value providing a count of the number of data rows in the View.

Remarks

Note that data rows can be hidden within collapsed groups when data grouping is applied. The DataRowCount property returns the total number of data rows regardless of whether they are within collapsed groups or not. Also, the property’s return value is not always the same as the number of records within the associated data source. When data filtering is applied, the DataRowCount property returns the number of rows that match the filter condition.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the DataRowCount member must not be invoked for these Views. The DataRowCount member can only be used with real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.

Example

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

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(); }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataRowCount property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also