Click here to Skip to main content
11,433,997 members (56,163 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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 1:38am
Edited 20-Jul-12 2:34am
(no name)94.3K
v2
Comments
Christian Graus at 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 at 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 at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.150428.2 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2015
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