Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want row to be added to table on combobox click how do I get the combobox to be clickable and add the row with selected text

What I have tried:

Have created the columns I need :

bindingsource.Add("mileage")
bindingsource.Add("CostofFuel")
bindingsource.Add("Date")
'---create a combobox column---
Dim comboBoxCol As New DataGridViewComboBoxColumn
'---set the header---
comboBoxCol.HeaderText = "Send To"
'---data bind it---
comboBoxCol.DataSource = bindingsource
'---add a combobox column to the DataGridView control---
DataGridViewINS.Columns.Add(comboBoxCol)
Posted
Comments
RDBurmon 12-Feb-16 22:45pm    
where you want row to be added? in database or in datagrid view?
geparl 13-Feb-16 13:47pm    
sorry I did not clarify I want the row added in the database
RDBurmon 13-Feb-16 22:38pm    
its very risky to add row in database on each click of combobox
just imaging what would happen if user clicks the combobox multiple times then table would have multiple entries. isn't it? The best way to achieve this scenario is add a "Update/SAVE" button and write code on button click event.

So user will add as much entries in to data grid view as they want and click on button to save the value to the database
geparl 16-Feb-16 12:04pm    
thank you but could I use the combobox to pick what table I wanted to fill and then use the update/save to add the data. I want to use the datagrid to add the same data to 2 tables

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900