Пример #1
0
        //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;
        }