• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 492
  • Last Modified:

ComboBox Selected Value changes when typed into

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?
Thanks
0
Sheritlw
Asked:
Sheritlw
  • 2
1 Solution
 
abelCommented:
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?
0
 
SheritlwAuthor Commented:
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.
0
 
abelCommented:
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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now