Question adding row to a bound combobox

st0kvis

New member
Joined
Jun 16, 2011
Messages
3
Programming Experience
3-5
my combobox is bound to an access datatable in access 2010

i used the drag and drop approach on a windows form and from there bound it by clicking on the combobox.
The data is displayed successfully

Want i want to add is on form load that the combobox should show PLEASE SELECT.

how can i do this without adding PLEASE SELECT to my access database...
 
There's no such thing as an Access DataTable and your ComboBox has nothing to do with Access. You query the Access database and populate a DataTable with a copy of the data. The DataTable has nothing specific to do with Access. It's contents could come from anywhere. The ComboBox is bound to the DataTable.

As for your question, you are certainly not the only person to ask this question but I have to say that it is the most pointless enterprise ever. Do you put a "Please Type" prompt in a TextBox? Of course not, because everyone knows that you type into a TextBox. Why would you then assume that people don't know that they need to select an item in a ComboBox?

If you really must do it then you need to consider what a bound control does: it displays the contents of its data source, i.e. you need the extra item in the DataTable. Just like any collection though, the fact that it already contains data doesn't mean that you can't add more. If you wanted to save a new record to the database, what would you do? You'd add a new row to the DataTable, right? So, why would this ne any different? That said, if you want this extra row to be first in the list then you'll need to Insert rather than Add.
 
Back
Top