Jump to content
Software FX Community

How to add my own Command to the Context Menu?


MasterMind
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 9 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...