• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Searching

The DataView exposes two methods that can be used to find rows: Find and FindRows. Both methods require that the DataView be sorted using either the ApplyDefaultSort or Sort property, and will find records based only on the column or columns that define the sort order. The Find method returns the index of the first row that matches the criteria, or –1 if no matching rows are found. FindRows returns an array of DataViewRow objects representing the matching rows. If no rows match the criteria passed to FindRows, the method returns an empty array.

Both methods are overloaded to find single- and multi-column sorts. If the DataView is sorted on a single column, you pass a single object, as shown in Listing 19-5. In the example, the value being sought is a string that is passed directly to the method. Because the argument is defined as an Object, you can pass any data type you require, either directly or by way of a variable.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint