Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Collapse]Processing Rows
     Traversing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Traversing Rows

This topic describes two row traversing techniques - traversing through data rows and currently visible rows. Note that row traversing doesn't involve row focus movement, merely accessing rows one by one. Such operations may be useful when you need to modify row data in a common manner, when you need to locate a particular row, etc. This topic doesn't provide information on processing group rows or traversing through master and detail rows. For details on those subjects, refer to the Process Group Rows, Expanding and Collapsing Master Rows and Navigating Through Master and Detail Rows topics.

Expanded Traversing Rows

As described in the Identifying Rows and Cards topics, all rows have corresponding integers called row handles. Data row handles are successive integers starting from 0. The last available data row handle is identified by different properties in different Views. In Card Views, cards cannot be hidden as a result of operations such as grouping. This means that row handles always match visible indexes. Thus, the last available data row handle is equal to the BaseView.RowCount property value decremented by one.

Grid Views support the grouping feature, which means that some data rows can be hidden within collapsed groups. In such Views, the BaseView.RowCount property value identifies the number of non-hidden rows. To determine the number of data rows, use the BaseView.DataRowCount property. Again, you need to decrement the property value by one to obtain the last available data row handle.

Once you have determined the number of data rows, you can traverse through all the data rows within a View. For this purpose, you only need a counter whose value is changed from 0 (the first data row's handle) to the obtained number (the last data row's handle). The sample code below shows how this can be implemented. It declares a method that reduces the Price column's values by 10 percent. Note that the code works for both card and Grid Views (the View is passed to the method as a parameter).

Note: the sample code above calls the ColumnView.BeginSort and ColumnView.EndSort methods to avoid data reloading while changing row data. This is useful, since changing cell values may lead to changing row order (together with row handles) if sorting is applied to the View.

You can also navigate rows using the ColumnView.GetVisibleRowHandle and ColumnView.GetNextVisibleRow methods. Both methods return a row handle that can be compared to the GridControl.InvalidRowHandle constant to determine if the last row has been passed. The code below shows an example of using these methods. The ColumnView.GetVisibleRowHandle method is used to obtain the first visible row's handle. The ColumnView.GetNextVisibleRow method is used to access successive rows.

Expanded See Also

How would you rate this topic?​​​​​​​