Exemplo n.º 1
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            Form addNew = new frmAddNewStudent();

            addNew.ShowDialog();
            listBoxStudents.Items.Clear();
            AddToListbox();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddNewStudent addNewForm     = new frmAddNewStudent();
            DialogResult     selectedButton = addNewForm.ShowDialog();

            //coming back from Add New Student Form
            if (selectedButton == DialogResult.OK && addNewForm.Tag != "")
            {
                //add new data to stringList
                listStudentScores.Add(addNewForm.Tag.ToString());
                lstStudentData.Items.Clear();
                foreach (string student in listStudentScores)
                {
                    lstStudentData.Items.Add(student);
                }

                //load stringList into Listbox with a for each loop
            }
        }