?
Solved

What event needs to be checked for a ComboBox when list is dropped down?

Posted on 2014-09-30
12
Medium Priority
?
137 Views
Last Modified: 2014-09-30
I have a scenario where a specific user likes to use a ComboBox in the capacity where they open the box by clicking on the down arrow. Then they start type a value and the List narrows as they type. When they come to the entry they want, they just hit the enter key to populate the CMB. What Event needs to be checked for that scenario? I was trying the KeyPress Event and that didn't quite give me the same thing. Here is how I have that Event coded.

    Private Sub cmbEquipmentNames_UOM_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cmbEquipmentNames_UOM.KeyPress
        Try
            If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Or e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Tab) Then
                cmbEquipmentNames_UOM.Text = cmbEquipmentNames_UOM.SelectedText
                txtEquipmentNames_LowerRange.Focus()
            End If

        Catch ex As Exception
            EH.ErrorMessage = "cmbEquipmentNames_UOM_KeyPress() - " & ex.Message & "~E"
        End Try

        EH.ProcessMessages(Me, sbr, EH.ErrorMessage)
    End Sub

Open in new window

0
Comment
Question by:BlakeMcKenna
[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
  • 6
  • 5
12 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 40352509
I'm not quite sure what you're asking, but I think the Style property may give you what you want without any events.
I think there's one for the style of typing letters to get an entry.
0
 

Author Comment

by:BlakeMcKenna
ID: 40352535
Basically, as the user types text, if the entry in the dropdown list appears in the textbox and that is what the user wants, they hit/press the enter key to accept that value.
0
 
LVL 9

Expert Comment

by:dustock
ID: 40352579
Try setting the AutoCompleteMode to Suggest, and set the AutoCompleteSource to ListItems

auto complete
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BlakeMcKenna
ID: 40352610
Ok,

Setting those properties worked. I know how to get the data from the ComboBox, I'm just never clear on the best events to use to get the actual value in the textbox as well as the SelectedValue. Can these values be retrieved in one Event? The User needs to have the freedom to select an item in the list or by enter text and have the "Suggest" functionality work to.
0
 
LVL 9

Expert Comment

by:dustock
ID: 40352669
As far as I know you'll need two separate events for the typing aspect and selecting.
0
 

Author Comment

by:BlakeMcKenna
ID: 40352683
I kinda figured that....but which ones?
0
 
LVL 9

Accepted Solution

by:
dustock earned 2000 total points
ID: 40352773
SelectedIndexChanged for when they manually select.  KeyPress event should work for when you type a value.  When you hit enter is it not selecting the value your typing?  I'm at lunch at the moment but I can help you work through any issues with the events when I'm done.  Let me know what events your having issues with, if any.
0
 

Author Comment

by:BlakeMcKenna
ID: 40352806
I'm using the KeyDown Event and that seems to be working. I check to see the if the "SelectedValue" property is > 0 and then use the "Text" property value. I'm trying the SelectionChangeCommitted Event but having issues with that. When I check the "SelectedValue" property...it has a value greater than zero, however, the "Text" property doesn't actually have a value until you make another selection. At that point, the "Text" value was the previous value. In other words. If, for the first time I select "Cat", the textbox is filled with the value "Cat", however, the actual "Text" property is empty. Now, if I select "Dog", the "Text" property now contains the value "Cat" even thought the textbox has the value of "Dog" in it.
0
 

Author Comment

by:BlakeMcKenna
ID: 40352810
Nevermind...for some reason, the "SelectionChangeCommitted" Event is working. Not sure what the issue was before.
0
 
LVL 9

Expert Comment

by:dustock
ID: 40352820
That's an interesting outcome, but sounds like you got it figured out now
0
 

Author Comment

by:BlakeMcKenna
ID: 40352834
I believe so...thanks for your help dustock!
0
 
LVL 9

Expert Comment

by:dustock
ID: 40352844
your welcome
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 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