System.Windows.Forms.ComboBox.ObjectCollection.RemoveAt C# (CSharp) Method

RemoveAt() public method

public RemoveAt ( int index ) : void
index int
return void
			public void RemoveAt (int index)
			{
				if (index < 0 || index >= Count)
					throw new ArgumentOutOfRangeException ("index");
				
				if (index == owner.SelectedIndex)
					owner.SelectedIndex = -1;
				
				object removed = object_items[index];
				
				object_items.RemoveAt (index);
				owner.UpdatedItems ();
				
				//UIA Framework event: Item removed
				OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Remove, removed));
			}
			#endregion Public Methods

Usage Example

Example #1
0
		public void RemoveAtTest ()
		{
			ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
			col.Add ("Item1");
			col.Add ("Item2");
			col.RemoveAt (0);
			Assert.AreEqual (1, col.Count, "#H1");
			Assert.AreEqual (true, col.Contains ("Item2"), "#H1");
		}