private void btnDelete_Click(object sender, EventArgs e) { try { if (GridView1.SelectedRowsCount == 0) { throw new Exception("Նշված տողեր չկան"); } if (MessageBox.Show("Ցանկանու՞մ եք ջնջել գրանցումը", "Հարցում", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DataRow rowData; int[] listRowList = GridView1.GetSelectedRows(); for (int i = 0; i < listRowList.Length; i++) { rowData = GridView1.GetDataRow(listRowList[i]); CL.RemoveAll((x) => x.ID == Convert.ToInt32(rowData["ID"].ToString())); } string json = JsonConvert.SerializeObject(CL, Formatting.Indented); System.IO.File.WriteAllText(@"Clients.db", json, Encoding.UTF8); RefreshGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }