private void ShowSubMenu(PopupMenuItem parentItem) { FlatPopupMenu subMenu = (FlatPopupMenu)subMenus[parentItem]; if (subMenu == null) { return; } subMenu.Show(); subMenu.Left = this.Left + this.Width; subMenu.Top = this.Top + itemsBounds[SelectedIndex].Top - 1; subMenu.BringToFront(); }
private void CreateSubMenu(MenuItem parentItem) { if (parentItem.MenuItems == null || parentItem.MenuItems.Count == 0) { return; } FlatPopupMenu childMenu = new FlatPopupMenu(); PopupMenuItem[] items = new PopupMenuItem[parentItem.MenuItems.Count]; foreach (MenuItem item in parentItem.MenuItems) { items[parentItem.MenuItems.IndexOf(item)] = (PopupMenuItem)item; } childMenu.SetItems(items); this.Parent.Controls.Add(childMenu); subMenus.Add(parentItem, childMenu); }