Example #1
0
 private void UpdateDisplay()
 {
     lbxItems.Items.Clear();
     if (bVolunteer)
     {
         arrItems  = arrVolunteers;
         this.Text = "Add Volunteers";
         lblUseInstruction.Text = "Select any volunteers from the list below. Use Ctrl to make multiple selections";
     }
     else
     {
         arrItems  = arrEquipment;
         this.Text = "Add Equipment";
         lblUseInstruction.Text = "Select any items of equipment from the list below. Use Ctrl to make multiple selections";
     }
     foreach (Object obj in arrItems)
     {
         string strNext = "";
         if (bVolunteer)
         {
             CVolunteer nextVol = (CVolunteer)obj;
             strNext = nextVol.DisplayData();
         }
         else
         {
             CEquipment nextEqu = (CEquipment)obj;
             strNext = nextEqu.DisplayData();
         }
         lbxItems.Items.Add(strNext);
     }
 }
        private void btnRemoveEquip_Click(object sender, EventArgs e)
        {
            frmAddItem dlg = new frmAddItem();

            dlg.IsVolunteer = false; //use the dialog to add equipment
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < dlg.SelectedItems.Count; i++)
                {
                    CEquipment Eqp = (CEquipment)dlg.SelectedItems[i];
                    if (!lbxEquipment.Items.Contains(Eqp.DisplayData()))
                    {
                        lbxEquipment.Items.Remove(Eqp.DisplayData());
                    }
                }
            }
        }