TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
Gabriel
- Newbie
- Posts: 5
- Joined: Fri Feb 26, 2010 12:00 am
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
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
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");
}
-
Gabriel
- Newbie
- Posts: 5
- Joined: Fri Feb 26, 2010 12:00 am
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
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
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 (99.05 KiB) Viewed 4585 times
Anyway, I'm glad to see that you've found a solution for it.
-
Gabriel
- Newbie
- Posts: 5
- Joined: Fri Feb 26, 2010 12:00 am
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
. 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