0

I have "binded" my Access database to the Datagridview in my form. I have added an event for double mouse click in datagridview row header.

private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {

            foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)

                dataGridView1.Rows.RemoveAt(item.Index);



            this.Validate();
            this.firearmBindingSource.EndEdit();
            this.firearmTableAdapter.Update(this.firearmsDataSet.Firearm);

        }

This code works(removes both view and source) on the first attempt upon the form loading at the start debugging. Any additional "double clicks" will remove row from the datagridview but not the source.

Where am I going wrong?

Thanks again.

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by Mitja Bonca
0

If you bind some data from the dataSource to DGV control, Remove the row from the datasource, not from the DGV. This will reflest in removing row from DGV as well.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.