Solved

Delete selection from a combobox

Posted on 2011-03-02
4
1,012 Views
Last Modified: 2012-05-11
Can't believe I cannot figure this one out...

I have a datagridview that has a combobox that is linked to a data table.  The list is populated very nicely, but I cannot delete the entry if I choose the incorrect item (I can change the item picked, but there might be times when this field is left blank).  I'm guessing this is a property setting of the combobox, but I cannot seem to find the right one.
0
Comment
Question by:bhlabelle
  • 2
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35021381
Hi,

If your combobox datasource is a table that do not have a blank value, that is the reason why it does not let you select a blank value.

You can add a value that represents blank such <Not Selected> to your combobox so the users can select that one, or you just add an empty value to match the blank.

Hope that helps
0
 

Author Comment

by:bhlabelle
ID: 35026758
How do I add an empty value to the combobox?  I assume it would be when the form loads, but I'm not sure how to do this.
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35028220
well, if you have a datatable as the datasource of your combobox you can do it like this, assuming your Table just have one Field

Dim drEmptyRow as DataRow

drEmptyRow = YourDataTable.NewRow
drEmptyRow("FieldName") = ""
YourDataTable.Rows.Add(drEmptyRow)

this code has to be just before you set the ComboBox Datasource
0
 

Author Closing Comment

by:bhlabelle
ID: 35028599
Well I do not know how/where to add the code to insert the blank line, so I will add an entry in my Access DB instead.  Thanks for your help.
0

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

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

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

19 Experts available now in Live!

Get 1:1 Help Now