开发者

about ToolStripMenuItem

开发者 https://www.devze.com 2023-03-03 16:27 出处:网络
I\'m having one ContextMenuStrip in that strip at runtime I\'m adding one ToolStripMenuItem. And I added this ContextMenuStrip in the XtraGridView\'s MouseDown() event handler. And at the same time I\

I'm having one ContextMenuStrip in that strip at runtime I'm adding one ToolStripMenuItem. And I added this ContextMenuStrip in the XtraGridView's MouseDown() event handler. And at the same time I've added the event handler for the newly inserted ToolStripMenuItem. And I have written one Event handler function for that ToolStripMenuItem. My problem of application is that when user right clicks on the XtraGridView it shows the required menu which I have added开发者_C百科 at runtime. And when I click on newly added ToolStripMenuItem it executes required event handler function but when I again do the same procedure the event handler function is executed for two times and so on...

Can anyone solve this problem?

Thanks.


You probably are subscribing to the Click event, in XtraGridView's click event. Each time the GridView's click event is raised causes you to subscribe to the click event handler again, so when user actually clicks on the ToolStripMenuItem all the handlers are called.

I suggest moving the subscription code to somewhere else.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号