windowsforms-devexpress-dot-xtraeditors-dot-gridlookupedit-a327268a.md
Fires after the GridLookUpEdit.AutoSuggest event is finished, and allows you to additionally customize the editor.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("Events")]
public event LookUpEditAutoSuggestCompleteEventHandler AutoSuggestComplete
<DXCategory("Events")>
Public Event AutoSuggestComplete As LookUpEditAutoSuggestCompleteEventHandler
The AutoSuggestComplete event's data class is DevExpress.XtraEditors.Controls.LookUpEditAutoSuggestCompleteEventArgs.
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.
private void AutoSuggestCompleteHandler(object sender, LookUpEditAutoSuggestCompleteEventArgs e) {
var edit = (GridLookUpEdit)sender;
if (e.QuerySuggestions.Result.Count == 1) {
var popup = edit.GetPopupEditForm();
popup.SelectedIndex = 1;
}
}
Private Sub AutoSuggestCompleteHandler(ByVal sender As Object, ByVal e As LookUpEditAutoSuggestCompleteEventArgs)
Dim edit = DirectCast(sender, GridLookUpEdit)
If e.QuerySuggestions.Result.Count = 1 Then
Dim popup = edit.GetPopupEditForm()
popup.SelectedIndex = 1
End If
End Sub
The following sample dynamically changes the drop-down panel height, depending on how many suggestions it shows.
void LookUpEdit1_AutoSuggestComplete(object sender, DevExpress.XtraEditors.Controls.LookUpEditAutoSuggestCompleteEventArgs e) {
var form = ((GridLookUpEdit)sender).GetPopupEditForm();
int recordCount = e.QuerySuggestions.Result.Count;
if(recordCount < "10") {
form.Size = new System.Drawing.Size(form.Width, recordCount*25);
}
}
Private Sub LookUpEdit1_AutoSuggestComplete(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.LookUpEditAutoSuggestCompleteEventArgs)
Dim form = DirectCast(sender, GridLookUpEdit).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