BindingList<person> p1; private void loadgrid() { p1 = new BindingList<person>(); p1.Add(new person() { PersonId = 1, Person_Name = "reden" }); p1.Add(new person() { PersonId = 2, Person_Name = "anne" }); dataGridView1.DataSource = p1; }
private void button1_Click(object sender, EventArgs e) { p1.RemoveAt(dataGridView1.SelectedRows[0].Index); }
foreach (DataGridViewCell oneCell in dataGridView1.SelectedCells) { p1.RemoveAt(dataGridView1.SelectedRows[0].Index); }
foreach (DataGridViewRow row in dataGridView1.SelectedRows) { if (!row.IsNewRow) { dataGridView1.Rows.Remove(row); } }
SelectedRows
Rows
.ToList()
foreach (DataGridViewRow row in dataGridView1.SelectedRows.ToList())
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)