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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.