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
243 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
ID: 17867381
can u post ur code?
0
 
LVL 35

Assisted Solution

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

Expert Comment

by:YZlat
ID: 17867991
wait, how do you load data into your ComboBox?
0
 

Author Comment

by:grouchyfd
ID: 17869056
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
ID: 17872841
use this
Combobox1.SelectedIndex = -1
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net 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 …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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