Solved

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

Posted on 2014-09-30
12
135 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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