i have been strugeling with this for some time now and its driving me crazy. This is the situation:
I have a bounded DataGridView
i designed this with the visual studio designer. All the information shows accordingly.
in my DataGridView
i have 2 ComboBoxes
in here the data is also correctly displayed. I want that if i click on the ComboBoxe
a list of options shows.
Because the DataGridView
is bounded to a source i can not use the ComboBox.Items.Add()
method. So i created another Datasource in the designer and in runtime i change the datasource
for that specific combobox. Now the list shows shows the options that i want, yeey !
Now, i want to save this newly added or changed row to the database.. so i use the following method for this (i call the method on the RowLeave
event from the DataGridView
):
if (tasksDataSet.HasChanges()
{
try
{
tasksBindingSource.EndEdit();
tasksDataSet.GetChanges();
tasksTableAdapter.Update(tasksDataSet);
}
catch (Exception ex)
{
}
}
This won't work for the ComboBoxes
since this is another datasource.
So basicly what i want is:
- Use a datasource for the
DataGridView
- Change/Add items to the
DataGridViewComboBox
- Save the changed made to the (complete)
DataGridView
to the database
How can i make this work ?