System.Windows.Forms.MenuItem.CloneMenu C# (CSharp) Méthode

CloneMenu() protected méthode

protected CloneMenu ( MenuItem itemSrc ) : void
itemSrc MenuItem
Résultat void
		protected void CloneMenu (MenuItem itemSrc)
		{
			base.CloneMenu (itemSrc); // Copy subitems

			// Window list
			MdiList = itemSrc.MdiList;
			is_window_menu_item = itemSrc.is_window_menu_item;
			// Remove items corresponding to window menu items, and add new items
			// (Otherwise window menu items would show up twice, since the PopulateWindowMenu doesn't
			// now them)
			bool populated = false;
			for (int i = MenuItems.Count - 1; i >= 0; i--) {
				if (MenuItems [i].is_window_menu_item) {
					MenuItems.RemoveAt (i);
					populated = true;
				}
			}
			if (populated)
				PopulateWindowMenu ();

			// Properties
			BarBreak = itemSrc.BarBreak;
			Break = itemSrc.Break;
			Checked = itemSrc.Checked;
			DefaultItem = itemSrc.DefaultItem;
			Enabled = itemSrc.Enabled;			
			MergeOrder = itemSrc.MergeOrder;
			MergeType = itemSrc.MergeType;
			OwnerDraw = itemSrc.OwnerDraw;
			//Parent = menuitem.Parent;
			RadioCheck = itemSrc.RadioCheck;
			Shortcut = itemSrc.Shortcut;
			ShowShortcut = itemSrc.ShowShortcut;
			Text = itemSrc.Text;
			Visible = itemSrc.Visible;
			Name = itemSrc.Name;
			Tag = itemSrc.Tag;

			// Events
			Events[ClickEvent] = itemSrc.Events[ClickEvent];
			Events[DrawItemEvent] = itemSrc.Events[DrawItemEvent];
			Events[MeasureItemEvent] = itemSrc.Events[MeasureItemEvent];
			Events[PopupEvent] = itemSrc.Events[PopupEvent];
			Events[SelectEvent] = itemSrc.Events[SelectEvent];
		}

Same methods

MenuItem::CloneMenu ( ) : MenuItem

Usage Example

Exemple #1
1
		public void CloneWindowMenuTest ()
		{
				MenuItem menuitem1 = new MenuItem ();
				menuitem1.MdiList = true;
				MenuItem menuitem2 = menuitem1.CloneMenu ();
				Assert.IsTrue (menuitem2.MdiList, "#1");
		}
All Usage Examples Of System.Windows.Forms.MenuItem::CloneMenu