ColumnView.LocateByDisplayText(Int32, GridColumn, String) Method

Locates rows by cells' display texts.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

public virtual int LocateByDisplayText(
    int startRowHandle,
    GridColumn column,
    string text
)
Public Overridable Function LocateByDisplayText(
    startRowHandle As Integer,
    column As GridColumn,
    text As String
) As Integer

Parameters

Name Type Description
startRowHandle Int32

An integer value specifying the handle of the row where the search starts.

column GridColumn

A GridColumn object (or descendant) specifying the column whose cells' display texts are compared to the search text.

text String

A string to search for.

Returns

Type Description
Int32

An integer value specifying the handle of the row found. If no matching row found, the GridControl.InvalidRowHandle field value is returned instead.

Remarks

Note: the LocateByDisplayText method is case-sensitive.

NOTE

In Instant Feedback Mode, this LocateByDisplayText method has limitations. It returns a correct value only if the target row has been loaded. Otherwise, it returns an invalid row handle (GridControl.InvalidRowHandle). See ColumnView.IsRowLoaded to learn whether a row has been loaded or not.

NOTE

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the LocateByDisplayText member must not be invoked for these Views. The LocateByDisplayText member can only be used with real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.

Examples

The following code shows how to select rows that contain "Mexico" in the Country column and copy data from these rows.

ColumnView.SelectRow-example.png

using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;

ColumnView view = gridControl1.MainView as ColumnView;
GridColumn colCountry = view.Columns["Country"];
GridColumn colCompany = view.Columns["CompanyName"];
if (colCountry == null || colCompany == null) return;

// Enable multiple row selection mode.
view.OptionsSelection.MultiSelect = true;
view.ClearSelection();
int rowHandle = -1;
// Select rows that contain 'Mexico' in the Country column.
while (rowHandle != GridControl.InvalidRowHandle) {
    rowHandle = view.LocateByDisplayText(rowHandle + 1, colCountry, "Mexico");
    view.SelectRow(rowHandle);
}
int[] selectedRowHandles = view.GetSelectedRows();
if (selectedRowHandles.Length > 0) {
    // Move focus to the first selected row.
    view.FocusedRowHandle = selectedRowHandles[0];
    // Copy the selection to the clipboard
    view.CopyToClipboard();
    // Copy the selected company names to a Memo editor.
    memoEdit1.Text = "";
    for (int i = 0; i < selectedRowHandles.Length; i++)
        memoEdit1.Text += view.GetRowCellDisplayText(selectedRowHandles[i], colCompany) + "\r\n";
}
See Also