[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


ComboBox Selected Value changes when typed into

Posted on 2009-04-18
Medium Priority
Last Modified: 2012-05-06
I have a combobox that allows users to create a new record and/or select a record and rename it through the combobox.
I also allow them to duplicate a record and then just rename it.
When they type into the combobox, there no longer is a selectedvalue.
How do I programmatically set when the combobox will hold it's selection?
Question by:Sheritlw
  • 2
LVL 39

Expert Comment

ID: 24177030
Not sure if I understand what you mean. Do you try to prevent people from selecting by typing, or do you want to allow them to select by typing when the focus is on the combobox?

Author Comment

ID: 24177065
No I want them to be able to Change the ComboText of an item selected from that combo only under certain circumstances.  When they change the text of a selected item to change the name, it loses the selectedvalue.
LVL 39

Accepted Solution

abel earned 2000 total points
ID: 24177145
When a user types into the edit section of a dropdown control, the control sends a TextUpdate event. With first change, i.e., with the first letter that a user types, the TextUpdate event is fired and the SelectedItem is still set valid and set. So what you can do inside the TextUpdate event is for instance:

    Private Sub ComboBox1_TextUpdate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.TextUpdate
        If ComboBox1.SelectedIndex = 3 Then
            MessageBox.Show("Sorry, not allowed")
            ComboBox1.Text = ComboBox1.SelectedItem
        End If
    End Sub

Open in new window


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

873 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