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
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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