gridControl add context menu

1. Drag from the toolbox to a standard control ContextMenuStrip form, appears under the control of the entire form, such as renaming contextPopMenu

2. Click on the small triangle in the upper right controls, add-member sub-menu MenuItem, note the name of the top emerging contextPopMenu is the name of the entire control can not be deleted, added MenuItem will appear below

3. Set the name and attribute for each text added MenuItem

4. Select the control you just created in contextPopMenu ContextMenuStrip property gdc (not gdv) in control

5. Add gdv control PopupMenuShowing event, post-processing right click, the pop-up menu before handling mechanism

6. PopupMenuShowing event based on the current state of the selected row, it is determined whether the pop-up menu, such as

            if (! btAlterFlt.Enabled) // edit mode unhooking the pop-up menus and controls the relationship, no right to achieve operating
                gdcFlts.ContextMenuStrip = null;
            the else
                gdcFlts.ContextMenuStrip = contextPopMenu;

    MenuItemEnterBuffer.Text = $ "buffer was added ({buffer.Count})"; // menu item name rewritable

7. processed in ItemClicked event contextPopMenu control

Right-click a menu item, gdv focus will switch to the current line, available through FocusRowHandel in this event, and then handle

if ((e.ClickedItem) .Name == " MenuItemBack") // processed according to the menu item clicked
 {...}

else if ((e.ClickedItem).Name == "MenuItemEnterBuffer")

{...}

Guess you like

Origin www.cnblogs.com/mol1995/p/11374746.html