Solved

Delete selection from a combobox

Posted on 2011-03-02
4
1,013 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

912 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

16 Experts available now in Live!

Get 1:1 Help Now