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
   [Collapse]Filtering and Locating Rows
    [Expand]Filtering
     Locating Rows in Code
     Incremental Search
     Searching via Find Panel
     Tutorial: Incremental Search
     Tutorial: Search/Find Panel
   [Expand]Focus and Selection Handling
   [Expand]Processing 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

Locating Rows in Code

This topic explains how to find rows based on the data. It describes two methods for locating rows by cell value, and explains how to implement a data search manually. Note that the search process implies traversing through data rows. Refer to the Traversing Rows topic for additional information on the methods used to iterate through rows.

Expanded Online Video

This video shows you how to filter and locate rows in code.

Expanded Locating Rows in Code

Sometimes you may need to locate rows by their field values. Use the ColumnView.LocateByValue method for this purpose. This method searches for the row that contains a specified value within a specific field. The row handle specifying the search start point is also passed as a parameter. A forward search is performed and the handle of the found row is returned.

You can also locate rows by the text displayed within their cells by using the ColumnView.LocateByDisplayText method. This method is similar to the ColumnView.LocateByValue method, but differs in that it compares the search value with display strings instead of cell values. Note that display strings are not just textual representations of field values. They may differ, for instance, if you implement cell value formatting, as described in the Formatting Cell Values topic.

The sample code below shows how to traverse the rows whose Category field contains 'SPORTS' .

Note

In Instant Feedback Mode (async server mode), the ColumnView.LocateByValue method must be called with an additional OperationCompleted[] completed parameter (see the method description to learn more).

Note that there may be cases when the ColumnView.LocateByValue and ColumnView.LocateByDisplayText methods do not meet your needs. For instance, you may need to find a particular group row. Another example is searching for a data row by multiple column values. In such cases, you will need to traverse data rows and determine whether or not they match the specified condition. The ColumnView.GetRowCellValue or ColumnView.GetRowCellDisplayText methods should be used to check to see if the row's data matches the specified values. The sample code below shows how this can be implemented. The LocateByMultipleValues method has the following parameters: a view, an array of columns and an array of values. This method traverses the View's data rows to find a row where a column from the columns array contains values in the values array. Note that this method also accepts the start row handle as a parameter. Thus, the method searches from the specified row to the last row within the View.

The sample code below shows how to use the declared method. It searches for the row that contains 'Condiments' in the CategoryName column and 2 in the CategoryID column. The search starts from the first data row within the View.

Expanded See Also

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