I want to open ContextMenuStrip when user right-click CustomPoint(Line,Area,Bar etc..).But
because of Steema's CustomPoint class doesnt inherit from System.Windows.Form.Control class,
it hasn't got ContextMenuStrip Property ...
How could i resolve this problem ?
Adding ContextMenuStrip to TeeChart controls (Series)
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi glikoz,
You could use this property from TChart which inherits form System.Windows.Form.Control and use a boolean flag for the cliked series as done here:
You could use this property from TChart which inherits form System.Windows.Form.Control and use a boolean flag for the cliked series as done here:
Code: Select all
private void Form1_Load(object sender, System.EventArgs e)
{
textBox1.ContextMenu = contextMenu1;
pictureBox1.ContextMenu = contextMenu1;
tChart1.ContextMenu=contextMenu1;
line1.FillSampleValues();
points1.FillSampleValues();
}
private bool flag = false;
private void series_Click(object sender, System.Windows.Forms.MouseEventArgs e)
{
if ((sender is Steema.TeeChart.Styles.CustomPoint) && (e.Button==MouseButtons.Right))
{
flag = true;
}
}
private void contextMenu1_Popup(object sender, System.EventArgs e)
{
// Define the MenuItem objects to display for the TextBox.
MenuItem menuItem1 = new MenuItem("&Copy");
MenuItem menuItem2 = new MenuItem("&Find and Replace");
// Define the MenuItem object to display for the PictureBox.
MenuItem menuItem3 = new MenuItem("C&hange Picture");
// Define the MenuItem objects to display for the Chart.
MenuItem menuItem4 = new MenuItem("&Copy");
MenuItem menuItem5 = new MenuItem("&Find and Replace");
// Clear all previously added MenuItems.
contextMenu1.MenuItems.Clear();
if(contextMenu1.SourceControl == textBox1)
{
// Add MenuItems to display for the TextBox.
contextMenu1.MenuItems.Add(menuItem1);
contextMenu1.MenuItems.Add(menuItem2);
}
else if(contextMenu1.SourceControl == pictureBox1)
{
// Add the MenuItem to display for the PictureBox.
contextMenu1.MenuItems.Add(menuItem3);
}
else if(contextMenu1.SourceControl == tChart1 && flag)
{
// Add the MenuItem to display for the Chart.
contextMenu1.MenuItems.Add(menuItem4);
contextMenu1.MenuItems.Add(menuItem5);
flag = false;
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |