private void metroTile4_Click(object sender, EventArgs e) { try { if (metroGrid1.Rows.Count > 0) { if (MessageBox.Show("هل تريد بالفعل حذف القسم المحدد ؟", "حذف المستخدم", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { lectures.DelLec(int.Parse(metroGrid1.CurrentRow.Cells[0].Value.ToString())); MessageBox.Show("تمت عمليه الحذف بنجاح", "حذف ", MessageBoxButtons.OK, MessageBoxIcon.Information); this.metroGrid1.DataSource = lectures.GetAllLec(); } } } catch { MessageBox.Show("هذه الخلية لا تحتوى على بيانات من فضلك اضغط على القسم المطلوب", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }