Jump to content
Software FX Community

Context Menu Question


Recommended Posts

 Is it possible to remove some of the items in the context menu that shows up when a user right mouse clicks on a chart?

I am using 


however, this keeps throwing a NullReferenceException.


Likewise, is it possible to add an item, previously removed, back into the context menu? What I want to do is, hide the Data Grid item until a certain condition is met. Once this condition is satisfied, show the Data Grid item.

I want to do the same thing to the Data Grid item on the toolbar as well.

Link to comment
Share on other sites

Hi wlo413.  Even though  the

command will always be present in the chart , you

can  hide the item to the end user. Following code show how to remove Pie Gallery item from Gallery Types



Int32 index = chart1.Commands[CommandId.Gallery].SubCommands.IndexOf((Int32)CommandId.Pie);



If you want to add it

again, you should use following code:



Link to comment
Share on other sites

 Ok, that example makes sense. However, which attribute of CommandID refers to the context menu?Also, when I apply the example to remove the Data Grid item from the tool bar in my code snippet: Int32 index = chart1.Commands[CommandId.ToolBar].SubCommands.IndexOf((Int32)CommandId.DataGrid);chart1.Commands[CommandId.ToolBar].SubCommands.RemoveAt(index);I get an ArgumentOutOfRangeException because the index is always returning -1. I can remove the DataGrid item from the toolbar by manually figuring out its index and using this:chart1.ToolBar.RemoveAt(14);But I can't seem to add the DataGrid item back becausechart1.Commands[CommandId.ToolBar].SubCommands.Add(CommandId.DataGrid);doesn't appear to be doing anything.

Link to comment
Share on other sites

 Hello Carlos

Thanks for the help, that was exactly what I needed. However to correct a typo in your code example to remove the Data Grid from the main context menu.

index = chart1.Commands[CommandId.



CommandID.Gallery should be replaced with CommandID.ContextMenuBack

I knew exactly what you meant though ;)


Link to comment
Share on other sites

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.

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.

  • Create New...