ClientFilterSortFind
---------------------------------------------------------------
Demonstrates filtering, sorting and searching of C1DataView rows.

This sample demonstrates filtering, sorting and searching
of C1DataView rows, which are performed on a client.

Sample form (Form1) contains a viewset (c1DataViewSet1) that is connected to the
nwindDataSet1 typed DataSet, with a single c1DataView having the following 
definition:
"Select Ord.OrderID, Ord.CustomerID, OrdDet.* From Orders Ord join [Order Details] OrdDet".
The definition is shown in the definitionTextBox TextBox. You can change the 
definition in run-time and then apply the changes by pressing the 
"Update Definition" button.

Form1 also contains a DataGrid (dataGrid1) that is connected to the view.


Sort

A sort order is defined in design-time in the view's Sort property as follows:
"ProductID DESC, Quantity". 
You can edit the Sort property in design-time by selecting the DataView.Sort 
property in the C1DataViewSet Editor.
The sort order definition is shown in run-time in the sortTextBox TextBox 
control with the "Sort" label. It can be changed and applied by pressing the 
"Apply" button at the right of this textbox.
Sort order can also be changed in run-time by pressing a column header of 
dataGrid1. After this, the current value of the Sort property showing in 
the textbox can be refreshed by pressing of the "Refresh with current view properties" 
button.


Filter

A filter is defined in design-time in the RowFilter property as follows:
"ProductID IS NOT NULL and UnitPrice > 10"
You can edit the RowFilter property in design-time by selecting the 
DataView.RowFilter property in the C1DataViewSet Editor.
The syntax of filter expression is the same as for the WHERE clause of
View Definition Language (the one used in the C1DataView.Definition property),
with the single exception that RowFilter expression references columns of 
C1DataView (C1ViewColumn objects) while View Definition Language's WHERE 
expression references columns of base DataTable(s).
RowFilter expression is shown in run-time in the filterTextBox TextBox 
with the "Filter" label.
It can be changed and applied by pressing the "Apply" button at the
right of this textbox.


Find

searchCondGridView DataGridView unbound control allows you to define the list
of values to search (Value column) and, if necessary, corresponding column 
names.


Find by Primary Key

Define the list of primary key values to search for in searchCondGridView,
by entering the values in the Value column (ColumnName column is ignored for this
type of search).
The number and order of values must be exactly the same as the number and order 
of columns constituting a primary key of the view. Primary key columns of the
current view are shown above the "Find by Primary Key" button.
Press the "Find by Primary Key" button - if a row has been found then it becomes
a current row, which you'll show in the grid, if not then the "Not found" dialog box 
appears.
The event handler code of this button collects values entered in the grid into an array
of objects and passes it to the c1DataViewSet1.FindByPrimaryKey method, which returns
an index of a row or -1 if not found. Note that it's not necessary to convert
values entered in the grid (which are strings) to the types of corresponding
columns; the FindByPrimaryKey method will do it automatically for you.
FindByPrimaryKey uses a binary search algorithm.


Find by Sort Key

Define the list of sort key values to search for in searchCondGridView,
by entering the values in the Value column (ColumnName column is ignored for this
type of search). The  order of values must correspond to an order of columns in sort key.
Note that you can specify fewer values than the length of the sort key and,
 in this case, search by subkey of the sort key will be performed.
Since, in general, there are multiple rows with the same key, you
can specify the row index from a set of found rows to return in the
combobox above the "Find by Sort Key" button, with possible choices:
First - the first one
Last - the last one
Accidental - what row will be returned is not guaranteed
Note that choosing the Accidental option returns the quickest search.
To perform this search the 
c1DataViewSet1.Find(object[], DuplicateKeyOccurenceEnum)
method is called; the first parameter is the list of key values, and the second one
corresponds to the First/Last/Accidental option.
The value returned by this method is an index of a row if it was found;
otherwise, it is a negative value which is the bitwise complement of the index of the 
next row whose key is larger than specified.
According to the returned value, a current row in a view is set to the found row
or to the nearest row with a greater sort key.
This Find method uses a binary search algorithm.


Find by arbitrary columns

Define the list of ColumnName-Value pairs in searchCondGridView by
entering a column name in the ColumnName column and a value in the Value column.
A ColumnName column value can be entered in the combobox containing a list of columns 
in the view. After you fill the searchCondGridView grid press the 
"Find by arbitrary columns" button.
Search is performed by means of the 
c1DataViewSet1.Find(string[] columnNames, object[] columnValues)
method, where columnValues[i] defines a value for a column with the name
columnNames[i]. It returns an index of a row or -1 if not found.
This method analyzes the set of searching columns and performs a binary search if 
it corresponds to primary key columns or sort key columns; , otherwise, a linear 
search will be performed.
