7

I want to remove a specific context menu item, appears when the Mouse down(right) event is fired.

enter image description here

with the help of Context Menu Builder event, I was able to add some costume menu items, but I want to get rid off the last item(Default).

Thanks in advance...

SanVEE
  • 2,009
  • 5
  • 34
  • 55

1 Answers1

6

In the same event handler, you can remove items as well, for example:

private void zedGraphControl1_ContextMenuBuilder(ZedGraphControl sender, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
{
  foreach (ToolStripMenuItem item in menuStrip.Items)
  {
    if ((string)item.Tag == "set_default")
    {
      menuStrip.Items.Remove(item);
      break;
    }
  }
}

Relevant Link: http://goorman.free.fr/ZedGraph/zedgraph.org/wiki/index43d0.html?title=Edit_the_Context_Menu

PeskyGnat
  • 2,454
  • 19
  • 22
  • Thanks a lot Pesky & Kudos for the Link as well...:) – SanVEE Jul 05 '12 at 13:37
  • @Editor don't go editing code in answers or questions. If you have an answer then please add your own answer and not edit others with your answer. – Popeye Apr 29 '13 at 12:36
  • @Popeye: actually it is ok to edit other peoples post: http://stackoverflow.com/faq#editing Of course if it comes to code it must not altered in a way that it does not reflect the initial idea anymore. – vikingosegundo Apr 29 '13 at 15:56
  • @vikingosegundo my apologies I will be a bit more specific. The editor tried to change the whole code snippet so it didn't reflect what the original post was. That is what I meant, I actually thought I had said that. Guess not my bad, thanks for correcting me. – Popeye Apr 29 '13 at 17:57