Solved

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

Posted on 2014-09-30
12
133 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

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 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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