private void ToolStripLabel1__Click(object sender, EventArgs e) { ToolStripLabel tsl = (ToolStripLabel)sender; Panel p = (Panel)tsl.Tag; PersonEditForm pef = new PersonEditForm((Person)p.Tag, this); pef.Visible = false; pef.ShowDialog(); Person person = pef.formPerson; p.Controls.Clear(); AddPersonToPanel(ref p, person); p.Refresh(); }
// handle clicking the Add button private void AddBtn__Click(object sender, EventArgs e) { // create a new Student object Person newPerson = new Student(); // disables this form this.Enabled = false; // create a new PersonEditForm and edit the newPerson Form personEditForm = new PersonEditForm(newPerson, this); // show form as non-modal // multi-threading, parallel processing - ie. PeopleList form and PersonEdit form are running in parallel //personEditForm.Show(); // show form as modal // PeopleList form pauses and waits until ShowDialog() returns //personEditForm.ShowDialog(); }
}//end add person to panel private void ToolStripLabel1__Click(object sender, EventArgs e) { ToolStripLabel tsl = (ToolStripLabel)sender; Panel p = (Panel)tsl.Tag; //create person edit from PersonEditForm pef = new PersonEditForm((Person)p.Tag, this); pef.Visible = false; //show the form, but only in a modal way(one at a time) pef.ShowDialog(); //get updated person obj out of form Person person = pef.formPerson; //clr contr in the panel p.Controls.Clear(); //method to add person to panel...modify contents of panel(modify -> explicit) AddPersonToPanel(ref p, person); p.Refresh(); }//end tool strip label 1