private void btnCreer_Click(object sender, EventArgs e) { Etudiant etudiant = new Etudiant ( txtNom.Text, txtPrenom.Text, txtIdentifiant.Text, txtLieu.Text, dateTimePicker1.Value, txtEmail.Text ); foreach (Etudiant s in etudiants) { if (etudiant.Equals(s)) { MessageBox.Show ( "Matricule already exists !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } } etudiants.Add(etudiant); MessageBox.Show ( "Save done.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information ); this.oldetudiant = null; txtIdentifiant.Clear(); txtNom.Clear(); txtPrenom.Clear(); txtLieu.Clear(); txtEmail.Clear(); txtNom.Focus(); lbEtudiants.Items.Add(etudiants[etudiants.Count - 1].FullName); lbEtudiants.ClearSelected(); lbEtudiants.SelectedIndexChanged += lbEtudiants_SelectedIndexChanged; }