//Add a new member private void btn_Add_Click(object sender, EventArgs e) { //Call class for fellowship member fMember newMember = new fMember(); //Call subform to reveal addMem add_Window = new addMem(this); add_Window.ShowDialog(); //Check if all fields are ready to receive if (!((CountryPass == null) && (NamePass == null) && (TitlePass == null))) { //Set Race string with Combo Box selected index setRace(RacePass); //Set Attributes... getFMemberData(newMember); //ADD member to fellowship Fellowship.Add(newMember); //Add to the listbox lbx_Members.Items.Add(newMember.Race + " - " + newMember.Name + " " + newMember.Title); } reset(); }
//Edit an entry private void btn_EditMem_Click(object sender, EventArgs e) { //Retrieve index of desired editing int index = lbx_Members.SelectedIndex; int raceID; //Create new PlaceHolder fMember pHolder = new fMember(); //Set placeholder member info to the same if (index < 0) { MessageBox.Show("Please select a member to Edit"); return; } raceID = setCbxIndex(Fellowship[index].Race); RacePass = raceID; CountryPass = Fellowship[index].Country; NamePass = Fellowship[index].Name; TitlePass = Fellowship[index].Title; WeaponPass = Fellowship[index].Weapon; //Call subform to reveal addMem add_Window = new addMem(this); add_Window.PopulateFields(); add_Window.ShowDialog(); // ----------------- if (!((CountryPass == null) && (NamePass == null) && (TitlePass == null))) { //Set Race string with Combo Box selected index setRace(RacePass); //Set Attributes... getFMemberData(pHolder); //Replace old values Fellowship[index] = pHolder; //Replace in ListBox lbx_Members.Items.Clear(); int i = 0; while (i < Fellowship.Count) { lbx_Members.Items.Insert(i, Fellowship[i].Race + " - " + Fellowship[i].Name + " " + Fellowship[i].Title); i++; } } //Toggle focus btn_Add.Focus(); //Set passing vars to null or zero Race = null; RacePass = 0; CountryPass = null; NamePass = null; TitlePass = null; WeaponPass = null; }