Context menu for Chart Editor object

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Gabriel
Newbie
Newbie
Posts: 5
Joined: Fri Feb 26, 2010 12:00 am

Context menu for Chart Editor object

Post by Gabriel » Tue Mar 02, 2010 8:21 am

Hi,
I've tried to implement a ContextMenuStrip for the Chart Editor, but it doesn't get enabled (strip is not displayed when right-click).
I've used the same-alike implementation (standard .net) I've done for the Chart object in another module of the application, where it works.
Thanks for any hints! The code follows:

Code: Select all

editChart = new TChart();
editor1 = new Steema.TeeChart.Editors.ChartEditor(editChart.Chart);
// .......
ToolStripMenuItem stripAfficheCharte = new ToolStripMenuItem("Action here");
contextMenu = new ContextMenuStrip();
contextMenu.Items.AddRange(new ToolStripItem[] { stripAfficheCharte });
stripAfficheCharte.Click += new System.EventHandler(stripAfficheCharte_Click);
editor1.ContextMenuStrip = contextMenu;

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Context menu for Chart Editor object

Post by Yeray » Thu Mar 04, 2010 8:32 am

Hi Gabriel,

Could you please tell us what exact TeeChart and Visual Studio version are you using? Here your code seems to works as expected:

Code: Select all

        private void button1_Click(object sender, EventArgs e)
        {
            Steema.TeeChart.TChart editChart = new Steema.TeeChart.TChart();
            Steema.TeeChart.Editors.ChartEditor editor1 = new Steema.TeeChart.Editors.ChartEditor(editChart.Chart);
            // .......
            ToolStripMenuItem stripAfficheCharte = new ToolStripMenuItem("Action here");
            ContextMenuStrip contextMenu = new ContextMenuStrip();
            contextMenu.Items.AddRange(new ToolStripItem[] { stripAfficheCharte });
            stripAfficheCharte.Click += new System.EventHandler(stripAfficheCharte_Click);
            editor1.ContextMenuStrip = contextMenu;
            editor1.Show();
        }

        void stripAfficheCharte_Click(object sender, EventArgs e)
        {
            MessageBox.Show("hello");
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Gabriel
Newbie
Newbie
Posts: 5
Joined: Fri Feb 26, 2010 12:00 am

Re: Context menu for Chart Editor object

Post by Gabriel » Thu Mar 04, 2010 10:10 am

Hi thanks, but it doesn't work as is (did u really try it?).
I've found the solution though: the context menu statements need to be executed during the editor1.Load event. And it works fine this way.
For info, I'm using your latest TeeChart release (just bought it) and VS 2008 and 2010 RC.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Context menu for Chart Editor object

Post by Yeray » Thu Mar 04, 2010 10:38 am

Hi Gabriel,

Yes I tied it. Here is the result I obtain in a new WinForms application. Simply adding a button, the teechart reference and the code above.
(Here I use Windows 7 x86, VS2008, TeeChart NET v4.0.2009.62332.)
contextmenu.png
contextmenu.png (99.05 KiB) Viewed 4589 times
Anyway, I'm glad to see that you've found a solution for it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Gabriel
Newbie
Newbie
Posts: 5
Joined: Fri Feb 26, 2010 12:00 am

Re: Context menu for Chart Editor object

Post by Gabriel » Thu Mar 04, 2010 10:50 am

Sorry if my comment seemed to be offensive, but just wanted to get into .net guts :wink: . In fact is not a Tchart issue here, but .net.
Combining our solutions, it converges to the fact that the context menu construction should be fired inside an event: the button for you, the load page in my case.
Cheers

Post Reply