How do I reset a combobox to a specific item in the items collection?

Posted on 2005-05-06
Last Modified: 2010-04-23
I have a form that is used to gather search criteria.  One of the controls is a button to clear all the fields to start a new search, another control is a combo box that is populated from the items collection of "NO", "YES", "MAYBE", "DON'T KNOW".  Because 95% of the time the answer is "NO", the user wants that to be the default value and it will only be changed rarely.   Here is what I have so far:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         Me.ComboBox.Text = "No"
     End Sub

    Public Sub ClearScreen(ByVal FormName As Form)
        Dim ctl As Control
        For Each ctl In FormName.Controls()
                If ctl.Tag Like "Init*" Then
                End If
     End Sub

This works great on form1_load.  My problem is when the user clicks the "Clear" button and I execute the same code I do on form1_load, the combobox is now empty.  How do I get it to display the "NO" again?
Question by:cswebdev
    LVL 4

    Expert Comment


      As long as you are not clearing the combo box you can do this:

      Me.ComboBox.SelectedIndex = Me.ComboBox.FindString("NO")
    LVL 4

    Accepted Solution

    Put the above code at the end of the ClearScreen method

    Author Comment

    I knew it had to be something simple I was missing!  Thank you very much.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now