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 btnAddVolunteer_Click(object sender, EventArgs e) { frmAddItem dlg = new frmAddItem(); dlg.IsVolunteer = true; //use the dialog to add volunteers if (dlg.ShowDialog() == DialogResult.OK) { for (int i = 0; i < dlg.SelectedItems.Count; i++) { CVolunteer vol = (CVolunteer)dlg.SelectedItems[i]; if (!lbxVolunteers.Items.Contains(vol.DisplayData())) { lbxVolunteers.Items.Add(vol.DisplayData()); } } } }