|
[C#]
private void InitializeChartData()
{
// Enable the context menu
this.chartControl1.ShowContextMenu = true;
//Event handler for context menu while pop up
this.chartControl1.ChartContextMenu.Popup += ChartContextMenu_Popup; }
private void ChartContextMenu_Popup(object sender, EventArgs e)
{
// Creating the chart context menu
ChartContextMenu menu = sender as ChartContextMenu;
// Creating the menu
MenuItem item = new MenuItem("Custom Menu");
// Added child menu in main menu
MenuItem item1 = new MenuItem("PrimaryXAxis",new EventHandler(Item_Click1));
MenuItem item2 = new MenuItem("PrimaryYAxis", new EventHandler(Item_Click1));
item.MenuItems.Add(item1);
item.MenuItems.Add(item2);
menu.MenuItems.Add(item);
} |
|
[C#]
private void InitializeChartData()
{
// Add custom tool bar
AddCustomToollBar();
}
private void AddCustomToollBar()
{
// Getting the image from image list
Bitmap bmp = new Bitmap(this.imageList1.Images[0]);
// Creating the custom tool bar
ChartToolBarDropDown dropdown = new ChartToolBarDropDown();
dropdown.Image = bmp;
//Added the custom toolbar into chart tool bar
this.chartControl1.ToolBar.Items.Add(dropdown);
// Created the custom menu
MenuItem item1 = new MenuItem("PrimaryXAxis", new EventHandler(Item_Click1));
item1.Checked = true;
item1.Name = "Checked";
MenuItem item2 = new MenuItem("PrimaryYAxis", new EventHandler(Item_Click1));
item2.Checked = true;
item2.Name = "Checked";
dropdown.Menu.MenuItems.Add(item1);
dropdown.Menu.MenuItems.Add(item2);
}
|
|
//To add the toolstrip items to the ContextMenuStrip
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyToolStripMenuItem,
this.pasteToolStripMenuItem,
this.cutToolStripMenuItem});
//To add the context menu to grid
this.gridControl1.ContextMenuStrip = this.contextMenuStrip1; |
Thank you so much! This looks great and i will try it out soon.