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
252 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

790 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