Solved

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

Posted on 2014-09-30
12
129 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

14 Experts available now in Live!

Get 1:1 Help Now