ColumnView.LocateByDisplayText(Int32, GridColumn, String) Method
Locates rows by cells’ display texts.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
public virtual int LocateByDisplayText(
int startRowHandle,
GridColumn column,
string text
)
#Parameters
Name | Type | Description |
---|---|---|
start |
Int32 | An integer value specifying the handle of the row where the search starts. |
column | Grid |
A Grid |
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 Grid |
#Remarks
Note: the LocateByDisplayText method is case-sensitive.
Note
In Instant Feedback Mode, this Locate
Note
Detail pattern Views do not contain data and they are never displayed within Xtra
- Grid
Control. - returns the top most View in a grid;Main View - Grid
Control. - returns the focused View;Focused View - Grid
Control. - returns the currently maximized View;Default View - the sender parameter of View specific events;
- Grid
View. - returns a detail clone View for a specific master row.Get Detail View
#Example
The following code shows how to select rows that contain “Mexico” in the Country column and copy data from these rows.
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";
}