Solved

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

Posted on 2014-09-30
12
131 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Accepted Solution

by:
dustock earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now