[]
        
(Showing Draft Content)

Search

You can easily perform search either on the entire list or just a specific column. This topic discusses how you can enable search in the List control.

Search List

To perform search operation, you can use Find method of the C1List class. This method has parameters that let you set the target string, comparison mode, field name to be searched, and much more. It also allows you to specify the row from where the search process should take place and provides various comparison options through the MatchCompareEnum parameter.


The following table describes all the options provided by the MatchCompareEnum enumeration.

Comparison Mode

Description

Equal

Searches for strings, numbers and dates that are equal to the stated value.

GreaterThan

Searches for strings, numbers and dates that are greater than the stated value.

GreaterThanOrEqual

Searches for strings, numbers and dates that are greater than or equal to the stated value.

IncludeEqual

Searches for a string inside another string.

LessThan

Searches for strings, numbers and dates that are less than the stated value.

LessThanOrEqual

Searches for strings, numbers and dates that are less than or equal to the stated value.

PartiallyEqual

Searches for the stated value in an incremental mode. This is the default mode.

Furthermore, you can also use MatchEntry property of the C1List class to specify how search should be performed based on the user's input. The MatchEntry property takes its value from the MatchEntryEnum enumeration which provides Extended, Standard, and None options.


The following code snippet demonstrates how to search a value from the entire list using the Find method.

var found = -1;            
//search in every column
for (int col = 0; col < c1List1.Columns.Count; col++)
{
     //search for the string
     found = c1List1.Find("search", C1.Win.List.MatchCompareEnum.PartiallyEqual, true, 0, col);
     //if found set the selected index
     if (found != -1)
     {
        c1List1.SelectedIndex = found;
        return;
     }
 }

Search in Column

To enable column-wise search in the List, you can use MatchCol property of the C1List class which its value from the MatchColEnum enumeration to specify the column fields to be searched.


The following table describes all the options provided by the MatchColEnum enumeration.

Options

Descriptions

AllCols

Searches all visible columns.

CurrentMousePos

Searches the column under current mouse cursor.

CurrentSelectedCol

Searches the current selected column.

DisplayMember

Searches the column of Display Member.

LeftVisibleCol

Searches the left most visible column.

RightVisibleCol

Searches the right most visible column.

The following code demonstrates how to enable search in all visible columns by setting the MatchCol property to AllCols.

c1List1.MatchCol = C1.Win.List.MatchColEnum.AllCols;