Back to Devexpress

LookUpEdit.AutoSuggestComplete Event

windowsforms-devexpress-dot-xtraeditors-dot-lookupedit-9a17d237.md

latest3.5 KB
Original Source

LookUpEdit.AutoSuggestComplete Event

Fires after the LookUpEdit.AutoSuggest event is finished. Allows you to additionally customize the editor.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event LookUpEditAutoSuggestCompleteEventHandler AutoSuggestComplete
vb
<DXCategory("Events")>
Public Event AutoSuggestComplete As LookUpEditAutoSuggestCompleteEventHandler

Event Data

The AutoSuggestComplete event's data class is DevExpress.XtraEditors.Controls.LookUpEditAutoSuggestCompleteEventArgs.

Remarks

In AutoSuggest mode, the Lookup editor fires the AutoSuggest event whenever a user enters text within it and dynamically changes the editor’s data source.

The AutoSuggestComplete event fires if the RepositoryItemLookUpEditBase.TextEditStyle property is set to Standard.

The code below focuses a suggestion in a drop-down list if this is the only suggestion found. As a result, a user can press Tab or Enter to select this suggestion, without having to press the Down arrow first.

csharp
void OnAutoSuggestComplete(object sender, LookUpEditAutoSuggestCompleteEventArgs e) {
    var edit = (LookUpEdit)sender;
    if (e.QuerySuggestions.Result.Count == 1) {
        var popup = edit.GetPopupEditForm();
        popup.SelectedIndex = 0;
    }
}
vb
Private Sub OnAutoSuggestComplete(ByVal sender As Object, ByVal e As LookUpEditAutoSuggestCompleteEventArgs)
    Dim edit = DirectCast(sender, LookUpEdit)
    If e.QuerySuggestions.Result.Count = 1 Then
        Dim popup = edit.GetPopupEditForm()
        popup.SelectedIndex = 0
    End If
End Sub

The following sample dynamically changes the drop-down panel height, depending on how many suggestions it shows.

csharp
void OnAutoSuggestComplete(object sender, LookUpEditAutoSuggestCompleteEventArgs e) {
    var form = ((LookUpEdit)sender).GetPopupEditForm();
    int recordCount = e.QuerySuggestions.Result.Count;
    if(recordCount < "10") {
    form.Size = new System.Drawing.Size(form.Width, recordCount*25);
    }
}
vb
Private Sub OnAutoSuggestComplete(ByVal sender As Object, ByVal e As LookUpEditAutoSuggestCompleteEventArgs)
    Dim form = DirectCast(sender, LookUpEdit).GetPopupEditForm()
    Dim recordCount As Integer = e.QuerySuggestions.Result.Count
    If recordCount < "10" Then
    form.Size = New System.Drawing.Size(form.Width, recordCount*25)
    End If
End Sub

See Also

LookUpEdit Class

LookUpEdit Members

DevExpress.XtraEditors Namespace