コード例 #1
0
        private void btnHomeEdit_Click(object sender, EventArgs e)
        {
            EditStudent     editStudent     = new EditStudent();
            EditStudentForm editStudentForm = new EditStudentForm();

            if (dgvStudents.SelectedRows.Count > 0)
            {
                string selectedRow = dgvStudents.SelectedRows[0].Cells[0].Value.ToString();

                foreach (DataGridViewRow row in dgvStudents.SelectedRows)
                {
                    editStudent.StudentID    = int.Parse(row.Cells[0].Value.ToString());
                    editStudent.FirstName    = row.Cells[1].Value.ToString();
                    editStudent.Surname      = row.Cells[2].Value.ToString();
                    editStudent.Email        = row.Cells[3].Value.ToString();
                    editStudent.Phone        = row.Cells[4].Value.ToString();
                    editStudent.AddressLine1 = row.Cells[5].Value.ToString();
                    editStudent.AddressLine2 = row.Cells[6].Value.ToString();
                    editStudent.City         = row.Cells[7].Value.ToString();
                    editStudent.County       = row.Cells[8].Value.ToString();

                    if (row.Cells[9].Value.ToString() == "Postgraduate")
                    {
                        editStudent.Level = "Postgraduate";
                    }
                    else if (row.Cells[9].Value.ToString() == "Undergraduate")
                    {
                        editStudent.Level = "Undergraduate";
                    }
                    editStudent.Course = row.Cells[10].Value.ToString();

                    editStudentForm.EditStudentList.Add(editStudent);
                }
                editStudentForm.Show();
            }
            else
            {
                MessageBox.Show("Select Full Row");
            }
        }
コード例 #2
0
        private void editStudentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditStudentForm editStudentForm = new EditStudentForm();

            editStudentForm.Show();
        }