System.Windows.Forms.ListBox.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 of out range");


#if NET_2_0
				//UIA Framework element removed
				object removed = object_items [index];
#endif
				UpdateSelection (index);
				object_items.RemoveAt (index);
				owner.CollectionChanged ();
				
#if NET_2_0
				//UIA Framework event: Item Removed
				OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Remove, removed));
#endif
			}
			#endregion Public Methods

Usage Example

Example #1
0
            private ListBox.ObjectCollection quicksort(ListBox.ObjectCollection list)
            {
                ListBox.ObjectCollection sorted = new ListBox.ObjectCollection(new ListBox());
                sorted.AddRange(list);

                if(sorted.Count <= 1)
                    return sorted;

                int random = randomNumberGenerator.Next(0, sorted.Count - 1);

                string pivot = (string)list[random];
                sorted.RemoveAt(random);

                ListBox.ObjectCollection lessThan = new ListBox.ObjectCollection(new ListBox());
                ListBox.ObjectCollection greaterThan = new ListBox.ObjectCollection(new ListBox());

                for(int i = 0; i < sorted.Count; ++i)
                    sortItem(sorted[i], pivot, lessThan, greaterThan);

                sorted = quicksort(lessThan);
                sorted.Add(pivot);
                sorted.AddRange(quicksort(greaterThan));

                return sorted;
            }