Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
if (!inited && ChartControl!=null )
{
MenuItem menuItem1 = new MenuItem("My Option-1", new EventHandler(MyOption1));
MenuItem menuItem2 = new MenuItem("My Option-2, new EventHandler(MyOption2));
int event1 = ChartControl.ContextMenu.MenuItems.Add(0, menuItem1);
int event2 = ChartControl.ContextMenu.MenuItems.Add(1, menuItem2);
int event4 = ChartControl.ContextMenu.MenuItems.Add(3, new MenuItem("-"));
ChartControl.MouseDown += new MouseEventHandler(OnMouseClick);
inited=true;
}
public void MyOption1(object sender, EventArgs e)
{
in here insert your action code
}
public void MyOption2(object sender, EventArgs e)
{
in here insert your action code
}
protected override void Dispose()
{
if (inited && ChartControl!=null)
{
ChartControl.ContextMenu.MenuItems.RemoveAt (1);
ChartControl.ContextMenu.MenuItems.RemoveAt (0);
ChartControl.ChartPanel.MouseDown -= new MouseEventHandler (this.OnMouseClick);
NT 7 upgraded ContextMenu to ContextMenuStrip.
You can see quick sample how to implement Context Menu Items in the attached file.
To PrTester and others: Please DO NOT bypass TriggerCustomEvent or you can end up messing up internal NinjaTrader Events and get unpredictable results and/or behavior.
P.S. Attached file is for NT7 only. NT 6.5 users do not bother trying it.
Roonius
Thanks for the code example - I am slightly confused though. You declare ToolStripitems yet place them in a contextmenustrip.
I haven't worked out what ontermination() does yet eitherbut I have only had beta for a day - it can't be instead of dispose which is where I would have put this code previously. EDIT -YES IT IS- NT7 does away with Dispose()
Just as I thought I had some kind of handle on NS it all changes (lol)
Edit - when you hover the mouse over Trigger Custom Event it now urges you to use another signature as it is deprecated?? Oops I see the new signature.
I have spent a fruitless 3 hours trying to get my menu to work using this Code structure but it won't.
I shall have to see if support can help ( that should be a laugh!)
Sorted it myself with Roonius' code example above.
Big thanks to Roonius for supplying the context menu snippet - saved me hours of searching.
I am brand new to NT7 and without that concept of ContextMenuStrip I have no idea how long it would have taken me to sort out.