void studentDeleteForm_FormClosing(object sender, FormClosingEventArgs e) { StudentDeleteForm studentDeleteForm = (StudentDeleteForm)sender; if (studentDeleteForm.IsConfirmed) { listBox1.Items.Remove(studentDeleteForm.FullName); } }
private void btnDeleteDialog_Click(object sender, EventArgs e) { StudentDeleteForm studentDeleteForm = new StudentDeleteForm(); studentDeleteForm.FullName = (string)listBox1.SelectedItem; DialogResult result = studentDeleteForm.ShowDialog(); if (result == DialogResult.Yes && listBox1.SelectedIndex > -1) { listBox1.Items.RemoveAt(listBox1.SelectedIndex); } }
private void btnDeleteStudent_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex >= 0) { StudentDeleteForm studentDeleteForm = new StudentDeleteForm(); studentDeleteForm.FullName = (string)listBox1.SelectedItem; studentDeleteForm.Show(); studentDeleteForm.FormClosing += studentDeleteForm_FormClosing; } else { MessageBox.Show("Silmek için bir satır seçin"); } }