private void dataGridViewClients_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; var indexItem = Convert.ToInt16(senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString()); if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { var but = (DataGridViewButtonColumn)senderGrid.Columns[e.ColumnIndex]; if (but.Text == "Изменить") { clients = GetIdClient(indexItem); AddClientForm f = new AddClientForm(clients); f.ShowDialog(); EditClient(f.item); } else { DeleteClient(indexItem); } var items = GetClients(); dataGridViewClients.DataSource = items; } }
private void button2_Click(object sender, EventArgs e) { AddClientForm f = new AddClientForm(); f.ShowDialog(); AddClient(f.item); var items = GetClients(); dataGridViewClients.DataSource = items; }