SIL.FieldWorks.TE.ImportWizard.btnDelete_Click C# (CSharp) Method

btnDelete_Click() protected method

protected btnDelete_Click ( object sender, EventArgs e ) : void
sender object Not used
e System.EventArgs Not used
return void
		protected void btnDelete_Click(object sender, EventArgs e)
		{
			// save the index of the first selected item so we can place the selection close
			// to there after deleting.
			Debug.Assert(m_lvCurrentMappingList.SelectedItems.Count > 0);
			int firstSelected = m_lvCurrentMappingList.SelectedIndices[0];

			// delete all of the selected items
			foreach (ListViewItem item in m_lvCurrentMappingList.SelectedItems)
			{
				ImportMappingInfo mapping = (ImportMappingInfo)item.Tag;
				m_lvCurrentMappingList.Items.Remove(item);
				m_settings.DeleteMapping(MappingSet.Main, mapping);
			}

			// if there are items in the list...
			if (m_lvCurrentMappingList.Items.Count > 0)
			{
				// restore the selection
				if (firstSelected >= m_lvCurrentMappingList.Items.Count)
					firstSelected = m_lvCurrentMappingList.Items.Count - 1;
				m_lvCurrentMappingList.Items[firstSelected].Selected = true;
			}
		}