ComponentFactory.Krypton.Toolkit.VisualContextMenu.Show C# (CSharp) Method

Show() public method

Show the context menu relative to the current mouse location.
public Show ( ) : void
return void
        public new void Show()
        {
            // Without a screen location we just place it at the same location as the mouse.
            Show(Control.MousePosition);
        }

Same methods

VisualContextMenu::Show ( Point screenPt ) : void
VisualContextMenu::Show ( Rectangle screenRect ) : void
VisualContextMenu::Show ( Rectangle screenRect, KryptonContextMenuPositionH horz, KryptonContextMenuPositionV vert ) : void
VisualContextMenu::Show ( Rectangle screenRect, KryptonContextMenuPositionH horz, KryptonContextMenuPositionV vert, bool bounce, bool constrain ) : void

Usage Example

        /// <summary>
        /// Show the context menu relative to the provided screen rectangle.
        /// </summary>
        /// <param name="caller">Reference to object causing the context menu to be shown.</param>
        /// <param name="screenRect">Screen rectangle.</param>
        /// <param name="horz">Horizontal location relative to screen rectangle.</param>
        /// <param name="vert">Vertical location relative to screen rectangle.</param>
        /// <param name="keyboardActivated">Was context menu initiated via a keyboard action.</param>
        /// <param name="constrain">Should size and position of menu be constrained by display size.</param>
        /// <returns>Has the context menu become displayed.</returns>
        public bool Show(object caller,
                         Rectangle screenRect,
                         KryptonContextMenuPositionH horz,
                         KryptonContextMenuPositionV vert,
                         bool keyboardActivated,
                         bool constrain)
        {
            bool displayed = false;

            // Only need to show if not already displaying it
            if (VisualContextMenu == null)
            {
                // Remember the caller for us in events
                Caller = caller;

                // Give event handler a change to cancel the open request
                CancelEventArgs cea = new CancelEventArgs();
                OnOpening(cea);

                if (!cea.Cancel)
                {
                    // Set a default reason for the menu being dismissed
                    CloseReason = ToolStripDropDownCloseReason.AppFocusChange;

                    // Create the actual control used to show the context menu
                    VisualContextMenu = CreateContextMenu(this, Palette, PaletteMode,
                                                          _redirector, _redirectorImages,
                                                          Items, Enabled, keyboardActivated);

                    // Need to know when the visual control is removed
                    VisualContextMenu.Disposed += OnContextMenuDisposed;

                    // Request the menu be shown immediately
                    VisualContextMenu.Show(screenRect, horz, vert, false, constrain);

                    // Override the horz, vert setting so that sub menus appear right and below
                    VisualContextMenu.ShowHorz = KryptonContextMenuPositionH.After;
                    VisualContextMenu.ShowVert = KryptonContextMenuPositionV.Top;

                    // Indicate the context menu is fully constructed and displayed
                    OnOpened(EventArgs.Empty);

                    // The menu has actually become displayed
                    displayed = true;
                }
            }

            return(displayed);
        }
All Usage Examples Of ComponentFactory.Krypton.Toolkit.VisualContextMenu::Show