System.Windows.Forms.ListBox.ObjectCollection.UpdateSelection C# (CSharp) Method

UpdateSelection() private method

private UpdateSelection ( int removed_index ) : void
removed_index int
return void
			void UpdateSelection (int removed_index)
			{
				owner.selected_indices.Remove (removed_index);

				if (owner.selection_mode != SelectionMode.None) {
					int last_idx = object_items.Count - 1;

					// if the last item was selected, remove it from selection,
					// since it will become invalid after the removal
					if (owner.selected_indices.Contains (last_idx)) {
						owner.selected_indices.Remove (last_idx);

						// in SelectionMode.One try to put the selection on the new last item
						int new_idx = last_idx - 1;
						if (owner.selection_mode == SelectionMode.One && new_idx > -1)
							owner.selected_indices.Add (new_idx);
					}
				}

			}