private void Button1_Click_2(object sender, EventArgs e) { Forms.FormStudent add_new_student = new Forms.FormStudent(studentClassBindingSource.Current as Class.StudentClass); if (add_new_student.ShowDialog() == DialogResult.OK) { } }
private void Button1_Click(object sender, EventArgs e) { Forms.FormStudent add_new_student = new Forms.FormStudent(new Class.StudentClass()); if (add_new_student.ShowDialog() == DialogResult.OK) { add_new_student.student.indeks = (lista_studentow.Count > 0) ? lista_studentow.Select(x => x.indeks).Max() + 1 : 1; lista_studentow.Add(add_new_student.student); } }