System.Windows.Forms.ListBox.SelectExtended C# (CSharp) Method

SelectExtended() private method

private SelectExtended ( int index ) : void
index int
return void
		private void SelectExtended (int index)
		{
			SuspendLayout ();

			ArrayList new_selection = new ArrayList ();
			int start = anchor < index ? anchor : index;
			int end = anchor > index ? anchor : index;
			for (int i = start; i <= end; i++)
				new_selection.Add (i);

			if (ctrl_pressed)
				foreach (int i in prev_selection)
					if (!new_selection.Contains (i))
						new_selection.Add (i);

			// Need to make a copy since we can't enumerate and modify the collection
			// at the same time
			ArrayList sel_indices = (ArrayList) selected_indices.List.Clone ();
			foreach (int i in sel_indices)
				if (!new_selection.Contains (i))
					selected_indices.Remove (i);

			foreach (int i in new_selection)
				if (!sel_indices.Contains (i))
					selected_indices.AddCore (i);
			ResumeLayout ();
		}