ColumnView.LocateByValue(Int32, GridColumn, Object, OperationCompleted[]) Method
Locates rows by cell values.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
public virtual int LocateByValue(
int startRowHandle,
GridColumn column,
object val,
params OperationCompleted[] completed
)
#Parameters
Name | Type | Description |
---|---|---|
start |
Int32 | An integer value specifying the handle of the row where the search starts. In server mode, this parameter must be set to 0. |
column | Grid |
The Grid |
val | Object | An object representing the value to search for. |
completed | DevExpress. |
A DevExpress. |
#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. The Grid |
#Remarks
The LocateByValue method doesn’t support a data search against compound field names (e.g. “Address.City”).
In regular binding mode, the LocateByValue method uses the Object.Equals method’s overload with two parameters to compare values.
In Server and Instant Feedback Modes, data is compared using the methods provided by an internal DataController. The startRowHandle parameter must be set to 0 in server mode.
Note
This note applies when Instant Feedback Mode is enabled.
In this mode, data is loaded by the grid control dynamically, in portions. When calling the Locate
To load the requested row and get its row handle, define a method of the DevExpress.
#Example
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;
}
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the LocateByValue(Int32, GridColumn, Object, OperationCompleted[]) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.