Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delete selection from a combobox

Posted on 2011-03-02
4
Medium Priority
?
1,037 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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 …
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 lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

772 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