|
sfComboBox2.DropDownOpening += SfComboBox2_DropDownOpening;
sfComboBox2.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
private void SfComboBox2_DropDownOpening(object sender, Syncfusion.WinForms.ListView.Events.DropDownOpeningEventArgs e)
{
e.Cancel=true;
} |
Hello,
Can you inform me please, what was the solution of this question?
I would like to prevent or cancel the user input (typing) when the item is not in the list.
Thank you!
BR, SZL
Hi Raahul,
Private Sub SfComboBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles SfComboBox1.KeyPress
If e.KeyChar = ControlChars.Back AndAlso e.KeyChar = ControlChars.Back Or Val(SfComboBox1.Text) >= 1 Then
Return
End If
Dim t As String = SfComboBox1.Text
Dim typed = t.Substring(0, SfComboBox1.Text.Length)
Dim newtext = typed & e.KeyChar
Dim view As List(Of Object) = SfComboBox1.DropDownListView.View.Items.ToList()
Dim filter As List(Of Object) = view.Where(Function(x) x.ToString().StartsWith(newtext, StringComparison.InvariantCultureIgnoreCase)).ToList()
If filter.Count = 0 Then
e.Handled = True
End If
End Sub
Regards,
Gokul T.