ColumnView.LocateByValue(String, Object, OperationCompleted[]) Method

Locates rows by cell values.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

public int LocateByValue(
    string fieldName,
    object val,
    params OperationCompleted[] completed
)
Public Function LocateByValue(
    fieldName As String,
    val As Object,
    ParamArray completed As OperationCompleted()
) As Integer

Parameters

Name Type Description
fieldName String

A string that specifies the target column's field name.

val Object

An object that is the value to search for.

completed DevExpress.Data.OperationCompleted[]

A DevExpress.Data.OperationCompleted method that will be called when the requested operation is completed. The method's argument will contain the requested value. This parameter is optional and is only required in Instant Feedback Mode.

Returns

Type Description
Int32

If the specified value is loaded, the method returns an integer value specifying the handle of the row found.

In Instant Feedback Mode, the DevExpress.Data.DataController.OperationInProgress value is returned if the requested search value is not currently loaded.

The GridControl.InvalidRowHandle value, if no row is found that matches the specified condition.

Remarks

The LocateByValue method performs a search from the top row. The method calls another LocateByValue overload with four parameters. See its description, to learn more about data searching.

Examples

This example shows how to use the LocateByValue method to search for a row in Instant Feedback Mode mode.

using DevExpress.XtraGrid.Views.Grid;

private void locateRowButton_Click(object sender, EventArgs e) {
    int rowHandle = gridView1.LocateByValue("Oid", 53498, OnRowSearchComplete);
    if (rowHandle != DevExpress.Data.DataController.OperationInProgress)
        FocusRow(gridView1, rowHandle);
}

void OnRowSearchComplete(object rh) {
    int rowHandle = (int)rh;
    if (gridView1.IsValidRowHandle(rowHandle))
        FocusRow(gridView1, rowHandle); 
}

public void FocusRow(GridView view, int rowHandle) {
    view.FocusedRowHandle = rowHandle;
}
See Also