Skip to main content

GridLookUpEdit.AutoSearchComplete Event

Fires when a search in AutoSearch mode completes.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DXCategory("Events")]
public event LookUpEditAutoSearchCompleteEventHandler AutoSearchComplete

Event Data

The AutoSearchComplete event's data class is DevExpress.XtraEditors.Controls.LookUpEditAutoSearchCompleteEventArgs.

Remarks

If the GridLookUpEdit.Properties.SearchMode property is set to AutoSearch, the editor automatically filters data source records in the drop-down window when the user enters a query in the edit box. The AutoSearch event fires before the data records are filtered and allows you to customize filter settings. The AutoSearchComplete event fires after the data records are filtered and allows you to perform custom actions. For example, you can automatically select a row or adjust the drop-down window height.

The GridLookUpEdit.AutoSearchComplete event is equivalent to the GridLookUpEdit.Properties.AutoSearchComplete event.

Example

In AutoSearch mode, the editor does not automatically select the first row that fits the entered query. If the search results contain only one row, you can handle the GridLookUpEdit.AutoSearchComplete event to automatically select this row as the code below demonstrates.

using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;

private void GridLookUpEdit1_AutoSearchComplete(object sender, DevExpress.XtraEditors.Controls.LookUpEditAutoSearchCompleteEventArgs e) {
    GridLookUpEdit edit = sender as GridLookUpEdit;
    GridView view = edit.Properties.View;
    if (view.RowCount == 1) {
        view.FocusedRowHandle = 0;
        gridLookUpEdit1.EditValue = view.GetFocusedRowCellValue(gridLookUpEdit1.Properties.ValueMember);
        gridLookUpEdit1.ClosePopup();
    }
}
See Also