//method that is run when add is selected from the menu strip private void addToolStripMenuItem_Click(object sender, EventArgs e) { //creates new dialogue for adding contact so that it will open multiple times instead of once. newDialogue = new AddingContact(); //shows the new dialogue so the user can see newDialogue.Show(); //creating subscribtion for custom event, this makes it so the NewDialouge_addContact code will run when this is hit. newDialogue.addContact += NewDialogue_addContact; }
//This method will allow users to edit an item private void editToolStripMenuItem_Click(object sender, EventArgs e) { //Creates a new instance of teh AddingContact form so that it will show up more then once in this situation. newDialogue = new AddingContact(); //Populates the addingcontact with the selected items information newDialogue.firstNameTextBox.Text = (listView1.SelectedItems[0].Tag as contactClass).FirstName; newDialogue.lastNameTextBox.Text = (listView1.SelectedItems[0].Tag as contactClass).LastName; newDialogue.phoneNumberTextBox.Text = (listView1.SelectedItems[0].Tag as contactClass).Number; newDialogue.emailTextBox.Text = (listView1.SelectedItems[0].Tag as contactClass).Email; newDialogue.mobileButton.Checked = (listView1.SelectedItems[0].Tag as contactClass).Mobile; newDialogue.workButton.Checked = (listView1.SelectedItems[0].Tag as contactClass).Work; newDialogue.homeButton.Checked = (listView1.SelectedItems[0].Tag as contactClass).Home; //Sets the edit button to being visible newDialogue.editButton.Visible = true; //shows Adding Contact form newDialogue.Show(); //subscription to the edit contact custom event, allow the NewDialouge code to run when this part is reached newDialogue.editContact += NewDialogue_editContact; }