private void UsunBT_Click(object sender, EventArgs e) { DataGridViewCheckBoxCell cell = null; BazaDanych baza = new BazaDanych(); foreach (DataGridViewRow row in dataGridView1.Rows) { cell = row.Cells[0] as DataGridViewCheckBoxCell; if (cell.Value != cell.TrueValue) { string numer = row.Cells[1].Value.ToString(); if (MessageBox.Show("Jesteś pewien, że chcesz usunąć klienta "+row.Cells[2].Value.ToString()+" "+row.Cells[3].Value.ToString()+"?", "Potwierdź", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { baza.UsunKlienta(Convert.ToInt32(numer)); } } } DataTable dt = baza.wykonajSelect("SELECT * FROM Klienci"); this.dataGridView1.DataSource = dt; }