windowsforms-devexpress-dot-xtraeditors-dot-lookupedit-38ac3650.md
Fires when a search in AutoSearch mode completes.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : 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 LookUpEdit.Properties.SearchMode property is set to AutoSearch, the editor automatically filters data source records in the drop-down window when the user enters a value in the text 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 LookUpEdit.AutoSearchComplete event is equivalent to the LookUpEdit.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 LookUpEdit.AutoSearchComplete event to automatically select this row as the code below demonstrates.
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Popup;
private void LookUpEdit1_AutoSearchComplete(object sender, DevExpress.XtraEditors.Controls.LookUpEditAutoSearchCompleteEventArgs e) {
LookUpEdit edit = sender as LookUpEdit;
PopupLookUpEditForm popup = edit.GetPopupEditForm();
if (popup.Filter.RowCount == 1) {
edit.ItemIndex = 0;
var value = edit.GetColumnValue(edit.Properties.ValueMember);
edit.ClosePopup();
edit.EditValue = value;
}
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Popup
Private Sub LookUpEdit1_AutoSearchComplete(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.LookUpEditAutoSearchCompleteEventArgs) _
Handles lookUpEdit1.AutoSearchComplete
Dim edit As LookUpEdit = TryCast(sender, LookUpEdit)
Dim popup As PopupLookUpEditForm = edit.GetPopupEditForm()
If popup.Filter.RowCount = 1 Then
edit.ItemIndex = 0
Dim value = edit.GetColumnValue(edit.Properties.ValueMember)
edit.ClosePopup()
edit.EditValue = value
End If
End Sub
See Also