windowsforms-devexpress-dot-xtraeditors-dot-gridlookupedit-044ab8f6.md
Fires when a search in AutoSearch mode completes.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("Events")]
public event LookUpEditAutoSearchCompleteEventHandler AutoSearchComplete
<DXCategory("Events")>
Public Event AutoSearchComplete As LookUpEditAutoSearchCompleteEventHandler
The AutoSearchComplete event's data class is DevExpress.XtraEditors.Controls.LookUpEditAutoSearchCompleteEventArgs.
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.
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();
}
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid.Views.Grid
Private Sub GridLookUpEdit1_AutoSearchComplete(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.LookUpEditAutoSearchCompleteEventArgs) _
Handles gridLookUpEdit1.AutoSearchComplete
Dim edit As GridLookUpEdit = TryCast(sender, GridLookUpEdit)
Dim view As GridView = edit.Properties.View
If view.RowCount = 1 Then
view.FocusedRowHandle = 0
gridLookUpEdit1.EditValue = view.GetFocusedRowCellValue(gridLookUpEdit1.Properties.ValueMember)
gridLookUpEdit1.ClosePopup()
End If
End Sub
See Also