Click here to Skip to main content
16,015,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Cb_party.AutoCompleteMode = AutoCompleteMode.Suggest
      Cb_party.AutoCompleteSource = AutoCompleteSource.CustomSource
      Cb_party.AutoCompleteCustomSource = party



using this code i assigned auto-complete to combobox....

After setting Auto-complete,the following code doesn't work.....

This code is used to check the selected item is listed or not in the combobox while pressing ENTER key....

Private Sub Cb_party_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Cb_party.KeyPress
        If e.KeyChar = ChrW(Keys.Enter) Then
            Dim i As Integer
            For i = 0 To Cb_party.Items.Count - 1
                If Cb_party.Items(i).Equals(Cb_party.Text) Then
                    txt_Km.Focus()
                    GoTo a
                End If
            Next
            MsgBox("Select Listed Item Only")
a:
        End If
    End Sub
Posted
Updated 20-Jul-12 1:34am
v2
Comments
Christian Graus 20-Jul-12 18:15pm    
Why use goto instead of break ? Wow, VB encourages bad code. Anyhow, what does 'doesn't work' mean ? Is the code called ? I reckon the auto complete might swallow the event ?
Sergey Alexandrovich Kryukov 20-Jul-12 19:30pm    
First of all, tag the application type of UI library used: WPF? ASP.NET? Forms? Silverlight? What?
--SA
Kenneth Haugland 20-Jul-12 19:42pm    
You should in any case replace GoTo a with Exit For or Exit sub, depending on wheter or not you would like the message box appear. GoTo will make your code into spagetti code... You cant find the end or start of anything.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900