public virtual DropdownMenu Show(Control control) { Close(); menu = CreateNewMenu(); menu.Size = new Size(control.Width + menu.Padding.Horizontal, 0); menu.Items.Clear(); foreach (object obj in this.Items) { menu.Items.Add(obj); } Rectangle controlRect = control.RectangleToScreen(control.ClientRectangle); Rectangle screenBounds = Screen.FromControl(control).WorkingArea; int menuHeight = menu.Height; if (controlRect.Bottom + menuHeight < screenBounds.Bottom) { menu.Location = new Point(controlRect.Left - menu.Padding.Left, controlRect.Bottom); } else { menu.Location = new Point(controlRect.Left - menu.Padding.Left, controlRect.Left - menuHeight); } menu.Show(); menu.FocusItem(SelectedIndex); return(menu); }
private DropdownMenu CreateNewMenu() { DropdownMenu menu = new DropdownMenu { Font = Font, MaxVisibleItems = this.MaxVisibleItems, ItemHeight = this.ItemHeight, StartPosition = FormStartPosition.Manual }; menu.ItemSelected += MenuItemSelected; return(menu); }
public virtual DropdownMenu Show(Rectangle bounds) { Close(); menu = CreateNewMenu(); menu.Size = bounds.Size; menu.Location = bounds.Location; menu.Items.Clear(); foreach (object obj in this.Items) { menu.Items.Add(obj); } menu.Show(); menu.FocusItem(SelectedIndex); return(menu); }
public DropdownCollection(DropdownMenu menu) { this.menu = menu; }