Click here to Skip to main content
12,396,047 members (65,981 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
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 20-Jul-12 0:38am
Updated 20-Jul-12 1:34am
Wes Aday104.2K
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100