/// <summary> /// adds a name to the list /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void addANameToTheListToolStripMenuItem_Click(object sender, EventArgs e) { InputForm input = new InputForm(); input.ShowDialog(); name = new Name(input.GetTextInput()); list = list + name; list.SetCount(); List.Items.Add(name); this.AmountOfNamesInList.Text = " Items in list:" + Convert.ToString(List.Items.Count); HasChanged = true; }
/// <summary> /// Lets the user remove a name from the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeANameFromTheListToolStripMenuItem_Click(object sender, EventArgs e) { InputForm input = new InputForm(); input.ShowDialog(); name = new Name(input.GetTextInput()); list = list - name; list.SetCount(); List.Items.Clear(); for (int i = 0; i < list.GetCount(); i++) //List.Items.Remove would not work so this is my workaround { List.Items.Add(list[i]); this.AmountOfNamesInList.Text = " Items in list:" + Convert.ToString(List.Items.Count); } HasChanged = true; }