I haven't done too much with DataGridViews in C# form applications so my approach is a rookie one I'm sure. Any help would be awesome!
My form is displaying the DataGridView for my database, and I want to give the user the option of deleting a particular row that is selected and then saving the changes.
Here is my code:
private void btnDeleteCustomer_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
{
dataGridView1.Rows.RemoveAt(item.Index);
dataGridView1.SelectAll();
}
}
private void btnSelectAll_Click(object sender, EventArgs e)
{
dataGridView1.SelectAll();
}
I am attempting to delete the selected row, then select all of the remaining rows, and then save the selected remaining rows with the click of one button. I'm sure there is a better way of doing so but I can't find a solution that works. Thanks!