/** * Opens the form to Add a new team - passes no data */ private void btnAddNewTeam_Click(object sender, EventArgs e) { Form addTeam = new frmTeam(); DialogResult button = addTeam.ShowDialog(); if (button == DialogResult.OK) { // Cast the contents of the Tag to a member and add to member list teams.Add((Team)addTeam.Tag); // reload the list box LoadListBox(); } }
/** * Opens the Edit teams form with the currently highlighted team in the tag * for editing */ private void btnEditSelectedTeam_Click(object sender, EventArgs e) { var selectedTeam = teams[lstTeams.SelectedIndex]; Form editTeam = new frmTeam(); editTeam.Tag = selectedTeam.Clone(); DialogResult button = editTeam.ShowDialog(); if (button == DialogResult.OK) { // Cast the contents of the Tag to a team and add to team list teams.Insert(lstTeams.SelectedIndex, (Team)editTeam.Tag); // remove the old team teams.RemoveAt(lstTeams.SelectedIndex + 1); // reload the list box LoadListBox(); } }