System.Windows.Forms.Menu.MenuItemCollection.RemoveAt C# (CSharp) Method

RemoveAt() public method

public RemoveAt ( int index ) : void
index int
return void
			public virtual void RemoveAt (int index)
			{
				if (index < 0 || index >= Count)
					throw new ArgumentOutOfRangeException ("Index of out range");

				MenuItem item = (MenuItem) items [index];
				MenuTracker tracker = owner.Tracker;
				if (tracker != null)
					tracker.RemoveShortcuts (item);
				item.parent_menu = null;

				items.RemoveAt (index);

				UpdateItemsIndices ();
				owner.OnMenuChanged (EventArgs.Empty);
			}

Usage Example

Example #1
0
        public void MenuItemCollection_RemoveAt_InvalidIndex_ThrowsArgumentOutOfRangeException(int index)
        {
            var menu       = new SubMenu(new MenuItem[] { new MenuItem() });
            var collection = new Menu.MenuItemCollection(menu);

            Assert.Throws <ArgumentOutOfRangeException>("index", () => collection.RemoveAt(index));
        }
All Usage Examples Of System.Windows.Forms.Menu.MenuItemCollection::RemoveAt