Solved

I need to clear the selection out of a combobox when it loads. How do I do this?

Posted on 2006-11-03
5
217 Views
Last Modified: 2010-04-23
I have a combobox that is bound to a datatable (in a relational database). There are 4 items in the tabel that it pulls the data from. When I load the form it comes up with the first item in the list. Unfortunately the item that is shown in the combobox when it loads or another item is saved to the database is duplicated in the combobox list. I still have 3 items in the combobox, but whatever was the last item in it when it was saved is duplicated. How do I stop this so it will always show all the different items listed and still be bound to the table I need? The only way I can get it to show the 4 different items is to unbind it from the related table. But then it won't update the table because of that. I don't want to enter the items in the items list property because then it would not show any other items. This list will change depending what is entered into it from another table.

Example:

Combobox A (actual)                                            Combobox B (waht I need)
Item 1                                                                 Item 1
Item 2                                                                 Item 2
Item 3                                                                 Item 3
Item 1                                                                 Item 4


Thanks




 
0
Comment
Question by:grouchyfd
5 Comments
 
LVL 8

Expert Comment

by:razo
Comment Utility
can u post ur code?
0
 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 250 total points
Comment Utility
ComboBox1.Items.Clear()
0
 
LVL 35

Expert Comment

by:YZlat
Comment Utility
wait, how do you load data into your ComboBox?
0
 

Author Comment

by:grouchyfd
Comment Utility
The collection of the list is loaded when the form loads:
Me.TableAdapter1.Fill(Me.DataSetName.Table)
This was generated automatically when I bound the combobox to the datasource.
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 250 total points
Comment Utility
use this
Combobox1.SelectedIndex = -1
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

11 Experts available now in Live!

Get 1:1 Help Now