DevExpress自定义Spreadsheetcontrol 单元格右键菜单

时间:2025-04-18 08:16:23
using ;
using ;
using ;
using ;

        private void spreadsheetControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
        {
            if ( == )
            {
                // Remove the "Clear Contents" menu item.
                ();

                // Disable the "Hyperlink" menu item.
                ();

                // Create a menu item for the Spreadsheet command, which inserts a picture into a worksheet.
                ISpreadsheetCommandFactoryService service = (ISpreadsheetCommandFactoryService)(typeof(ISpreadsheetCommandFactoryService));
                SpreadsheetCommand cmd = ();
                SpreadsheetMenuItemCommandWinAdapter menuItemCommandAdapter = new SpreadsheetMenuItemCommandWinAdapter(cmd);
                SpreadsheetMenuItem menuItem = (SpreadsheetMenuItem)();
                 = true;
                (menuItem);

                // Insert a new item into the Spreadsheet popup menu and handle its click event.
                SpreadsheetMenuItem myItem = new SpreadsheetMenuItem("My Menu Item", new EventHandler(MyClickHandler));
                (myItem);
            }
        }

        public void MyClickHandler(object sender, EventArgs e)
        {
            ("My Menu Item Clicked!");
        }