private void viewLeft_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { SelectedStudent = (sender as DataGridView)[1, e.RowIndex].Value as Classes.Student; }
private void buttonMoveToRight_Click(object sender, EventArgs e) { List<string> noGrades = new List<string>(); foreach (DataGridViewRow row in viewLeft.SelectedRows) { if (row.Cells[1].Value == SelectedStudent) SelectedStudent = null; viewRight.Rows.Add(row.Cells[0].Value, row.Cells[1].Value); viewLeft.Rows.Remove(row); } viewRight.Sort(viewRight.Columns[0], ListSortDirection.Ascending); viewLeft.ClearSelection(); viewRight.ClearSelection(); }
private void buttonRemoveRight_Click(object sender, EventArgs e) { //Dialog Box for confirmation if (MessageBox.Show("Are you sure you would like to remove the selected items?", "Remove Alert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) return; //Remove selected rows in right list foreach (DataGridViewRow item in viewRight.SelectedRows) { if (item.Cells[1].Value == SelectedStudent) SelectedStudent = null; viewRight.Rows.Remove(item); } viewRight.ClearSelection(); }
private void buttonImport_Click(object sender, EventArgs e) { // Show file dialog for the imported file to be chosen OpenFileDialog fd = new OpenFileDialog(); fd.Multiselect = false; if (fd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; DataTable studentTable = new Classes.Reader(fd.FileName).ReadFile(); //Fills left list with students in file foreach (DataRow row in studentTable.Rows) { Classes.Student stu = new Classes.Student() { Name = row["StuName"].ToString(), NameReversed = row["StuNameReversed"].ToString(), Address = row["Street"].ToString(), CityZipState = row["CityStateZip"].ToString(), HighSchool = row["HighSchool"].ToString(), ClassName = row["ClassName"].ToString(), Session = row["Session"].ToString(), SemesterNetAbs = Convert.ToInt32(row["SemesterNetAbs"]), SemesterTotalAbs = Convert.ToInt32(row["SemesterTotalAbs"]), SemesterTotalTdy = Convert.ToInt32(row["SemesterTotalTdy"]), }; viewLeft.Rows.Add(stu.NameReversed, stu); } }