Combo Box - change other boxes when value manually entered


     I have a windows app with a combo box.  The user selects a set number and then the set type displays in a disabled text box beside it.  This works fine if the user selects it in the combo box, using the selected_index_changed method.  But if someone types in a valid set number, while it repositions the combo box onto that set number, the text box doesn't update.  I've tried using the same code in the Enter, selected_Value_change, and changecommitted methods but those don't work either.  Is there a way to catch when someone types in the set number in the box and then tabs or clicks out of the box?

Who is Participating?
RonaldBiemansConnect With a Mentor Commented:
Change the dropdownstyle to dropdownlist

to answer the first question maybe try something like this

    Private Sub ComboBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
        Dim x As Integer = ComboBox1.Items.IndexOf(ComboBox1.Text)
        ComboBox1.SelectedIndex = x
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox2.Text = ComboBox1.SelectedItem
    End Sub
Hi gleznov,

You could trap the "Leave" event. Or the "Validating" or "Validated" events.

Look in your help for the ComboBox class events, and look at Leave - it contains a nice explanation of which events are fired, in which order.

Hope this helps,

gleznovAuthor Commented:
OK sorry to change the question up but how can I just make the combo box so that they can't type into it?  I know I've done this before but I've been working with web apps so long now I can't remember, and I can't find the property.  I'm getting errors when I try to trap the leave event, so I'd rather just cut that ability altogether.

gleznovAuthor Commented:
Couldn't get it working, just set them to dropdownlist.  Thanks!

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.

All Courses

From novice to tech pro — start learning today.