MasterMind Posted December 16, 2009 Report Share Posted December 16, 2009 Hello, I would like to create my own item in the Context Menu (the one that appears when righ-clicking on a chart). I've tried: Command myCommand = this.Commands[CommandId.ContextMenuBack]; myCommand.SubCommands.Add(CommandId.About); But the method Add() of SubCommands only takes a CommandId, so I don't see how I can add my own item. Thank you! Quote Link to comment Share on other sites More sharing options...
CarlosAC Posted December 16, 2009 Report Share Posted December 16, 2009 Hi MasterMind You can customize the toolbar or contextMenu, adding items. Then you can code the action you want for each item. Following is a code sample showing how you can add a toolbar item. // Creates a new command with CommandId CommandCollection commands = chart1.Commands; Command command = new Command (1); command.Style = CommandStyles .TwoState; command.Text = "New Toolbar Entry" ; command.ImageIndex = 1; // Adds the new command to the commands collection chart1.Commands.Add(command); // Creates a new toolbar entry and inserts it after the specified position ToolBarItem tbItem = new ToolBarItem (); tbItem.CommandId = 1; chart1.ToolBar.Insert(0, tbItem); Following is a code sample how you can code the action for the toolbar item. private void chart1_UserCommand( object sender, CommandUIEventArgs e) { if (e.CommandId == "Your Command ID" ) { // Your code goes here... } } -- Pipon Quote Link to comment Share on other sites More sharing options...
MasterMind Posted December 16, 2009 Author Report Share Posted December 16, 2009 Wow, this is a pretty fast answer! I just didn't realize I could create a custom Command with its own ID... This solution works perfectly, thank you very much! Quote Link to comment Share on other sites More sharing options...
kejawms Posted October 5, 2010 Report Share Posted October 5, 2010 Is there an example in VB.net???? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.