Skip to main content

RepositoryItemLookUpEdit.AutoSearchComplete Event

Fires when a search in AutoSearch mode completes.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.2.dll

Declaration

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

Event Data

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

Remarks

If the 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.

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 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;
    }
}
See Also