Combo Box - change other boxes when value manually entered

Posted on 2005-04-22
Last Modified: 2011-08-18

     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?

Question by:gleznov
    LVL 2

    Expert Comment

    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,


    Author Comment

    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.

    LVL 25

    Accepted Solution

    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

    Author Comment

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


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    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…
    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 …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    731 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

    15 Experts available now in Live!

    Get 1:1 Help Now