selecting a combobox item at runtime.

Posted on 2007-10-14
Last Modified: 2013-11-26
I am using a combBox, I want to select an item at runtime. When the form is loading the combbox is populated with values. At one time I have to populate the form with data from the database. When editing is done on the form it should replace the original form. below is a line from my code.

 Me.tlevel.Text = gcl.ReturnLevel(drd("tlevel"))

tlevel is a combobox, drd("tlevel") is a level id from a datareader "drd". actually it the (index of the selected item in the combobox) + 1, so gcl.ReturnLevel(drd("tlevel")) displays the label for that index.  But as it is loading I want it also selected because when iam saving i read the (id of the selected item) + 1 and i save that value. i use structures to populate the combobox. I am using
Question by:Anthony Matovu
    1 Comment
    LVL 48

    Accepted Solution

    Didn't understant very well you point but what produces gcl.ReturnLevel(drd("tlevel")) ? And how to you fill the combobox ?

    Have you tried already this
    ComboBox1.SelectedIndex = ComboBox1.FindString(YourStringValue)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    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…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    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…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 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

    10 Experts available now in Live!

    Get 1:1 Help Now