About ToolStripMenuItem

I have one ContextMenuStripin this strip at runtime. I add one ToolStripMenuItem. And I added this ContextMenuStrip to the XtraGridView MouseDown () event handler. And at the same time, I added an event handler for the newly inserted ToolStripMenuItem. And I wrote one event handler function for this ToolStripMenuItem tool. My problem is that when the user right-clicks on the XtraGridView, it shows the necessary menu that I added at runtime. And when I click on the recently added ToolStripMenuItem, it performs the required function of the event handler, but when I perform the same procedure again, the function of the event handler is executed twice, etc ...

Can anyone solve this problem?

Thank.

+3
source share
1 answer

You are probably subscribed to the Click event, in the XtraGridView click event. Each time the GridView click event is fired, you can again subscribe to the click event handler, so when the user clicks on ToolStripMenuItem, all handlers are called.

I suggest moving the subscription code to another location.

+4
source

All Articles