我已经设法过滤我的组合框,以便它过滤并显示正确的记录,即当键入 A 时显示所有 A 记录,键入 B 时显示所有 B 记录,依此类推。但是,当在组合框中找不到记录时,是否可以显示一个消息框?
我到目前为止的编码是:-
Private Sub cmblogged_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cmblogged.KeyPress
If Char.IsControl(e.KeyChar) Then Return
With Me.cmblogged
Dim ToFind As String = .Text.Substring(0, .SelectionStart) & e.KeyChar
Dim Index As Integer = .FindStringExact(ToFind)
If Index = -1 Then Index = .FindString(ToFind)
If Index = -1 Then Return
.SelectedIndex = Index
.SelectionStart = ToFind.Length
.SelectionLength = .Text.Length - .SelectionStart
e.Handled = True
End With
End Sub