private void ButtonEditStudent_Click(object sender, EventArgs e) { if (DataViewGrid.SelectedCells.Count == 0) { return; } var F = new StudentAddForm(this); var Index = DataViewGrid.SelectedCells[0].RowIndex; var Student = Students[Index]; F.SetData(Student); var DR = F.ShowDialog(); if (DR == DialogResult.OK) { var S = F.GetStudent(); Students[Index] = S; //MessageBox.Show(StudentsViewGrid.DataSource.ToString()); ((List <Student>)DataViewGrid.DataSource)[Index] = S; //StudentsViewGrid.E SetDataSource(Students); } }
private void AddButton_Click(object sender, EventArgs e) { var StudentAddForm = new StudentAddForm(this); var Result = StudentAddForm.ShowDialog(); if (Result == DialogResult.OK) { int ID = Students.Count + 1; var Student = StudentAddForm.GetStudent(); Student.ID = ID; Students.Add(Student); SetDataSource(Students); } }
private void ButtonEditStudent_Click(object sender, EventArgs e) { if (DataViewGrid.SelectedCells.Count == 0) { return; } var F = new StudentAddForm(this); var Index = DataViewGrid.SelectedCells[0].RowIndex; var Student = Students[Index]; F.SetData(Student); var DR = F.ShowDialog(); if (DR == DialogResult.OK) { var S = F.GetStudent(); Students[Index] = S; //MessageBox.Show(StudentsViewGrid.DataSource.ToString()); ((List<Student>)DataViewGrid.DataSource)[Index] = S; //StudentsViewGrid.E SetDataSource(Students); } }