Solved

F1 F1 F1 --- Combo box issue

Posted on 2004-08-12
5
231 Views
Last Modified: 2010-04-23
Hi,

I have created a custom combo box control. It goes to the matching entry in the list as you type. It works great all times BUT if the combo is dropped down (combo.DroppedDown = True) and the user types in an item  & hits TAB key then it does not work.

When the user types with drop-down portion visible, it correctly selects the matching item and displays but when the user hits TAB it goes to the previous item that was selected in the combo and not the new item. Surprisingly on the combo's lostfocus/leave, when I do combo.selectedValue I get the correct value of new item but it just does not select and highlight the new item in the combo.

Any help would be greatly appreciated.

Thanks!
0
Comment
Question by:jmnason
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 11783712
Are you wanting to go to the next control when you press tab?
0
 

Author Comment

by:jmnason
ID: 11783757
Yes. It goes to the next control correctly. The problem is the combo box is not highlighting/selecting the newly selected item.
0
 
LVL 27

Accepted Solution

by:
planocz earned 500 total points
ID: 11783819
Iam not sure which code you are using to select item.

Here is a sample of typeahead cbo code that I use that I think will work for you.
cbo is the comboBox control....

       Private Sub cbo_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cbo.KeyUp
            AutoCompleteCombo_KeyUp(sender, e)
        End Sub
        '********************* Better way of doing Type Head *************************
        Public Shared Sub AutoCompleteCombo_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs)
            '**************
            ' you can use it 2 ways.

            'either add the handles keyword after the sub name to handle your KeyUp event
            'eg. Public Shared Sub AutoCompleteCombo_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs) Handles cboSuburb.KeyUp

            'or

            'i use it as a generic sub so call it from the KeyUp event as follows:

            '  Private Sub cboSuburb_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboSuburb.KeyUp
            '            AutoCompleteCombo_KeyUp(sender, e)
            '        End Sub
            '**************
            Dim sTypedText As String
            Dim iFoundIndex As Integer
            Dim oFoundItem As Object
            Dim sFoundText As String
            Dim sAppendText As String

            'Allow select keys without Autocompleting
            Select Case e.KeyCode
                Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down
                    Return
            End Select

            'Get the Typed Text and Find it in the list
            sTypedText = cbo.Text
            iFoundIndex = cbo.FindString(sTypedText)

            'If we found the Typed Text in the list then Autocomplete
            If iFoundIndex >= 0 Then

                'Get the Item from the list (Return Type depends if Datasource was bound
                ' or List Created)
                oFoundItem = cbo.Items(iFoundIndex)

                'Use the ListControl.GetItemText to resolve the Name in case the Combo
                ' was Data bound
                sFoundText = cbo.GetItemText(oFoundItem)

                'Append then found text to the typed text to preserve case
                sAppendText = sFoundText.Substring(sTypedText.Length)
                cbo.Text = sTypedText & sAppendText

                'Select the Appended Text
                cbo.SelectionStart = sTypedText.Length
                cbo.SelectionLength = sAppendText.Length

            End If
        End Sub
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question