This is a migrated thread and some comments may be shown as answers.

Embed custom palette in the default ContextMenu

1 Answer 97 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 28 May 2013, 09:03 PM
Something like chartview-customization-palettes but not quite. I can define a custom palette simple enough. However, how do we embed it in the default Palettes ContextMenu?

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 31 May 2013, 02:42 PM
Hi Michael,

Thank you for writing.

To do that you need to capture the ContextMenuOpening event of RadChartView, where you can add your custom item:
radChartView1.ChartElement.ContextMenuOpening += ChartElement_ContextMenuOpening;
 
...........
 
void ChartElement_ContextMenuOpening(object sender, ChartViewContextMenuOpeningEventArgs e)
{
    RadMenuItem item = new RadMenuItem();
    item.Text = "Custom palette";
    item.Click += item_Click;
    e.ContextMenu.Items.Add(item);
}
 
void item_Click(object sender, EventArgs e)
{
    this.radChartView1.Area.View.Palette = new CustomPalette();
}
 
public class CustomPalette : ChartPalette
{
    public CustomPalette()
    {
        this.GlobalEntries.Add(Color.Yellow, Color.Red);
        this.GlobalEntries.Add(Color.Yellow, Color.Blue);
    }

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.
 

Regards,
Stefan
Telerik
RadChart for WinForms is obsolete. Now what?
Tags
ChartView
Asked by
Travis
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or