Click here to Skip to main content
12,954,672 members (72,078 online)
Rate this:
Please Sign up or sign in to 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
                    GoTo a
                End If
            MsgBox("Select Listed Item Only")
        End If
    End Sub
Posted 20-Jul-12 0:38am
Updated 20-Jul-12 1:34am
Wes Aday104.2K
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?
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
OriginalGriff 6,539
CHill60 3,490
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2017
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