关于 ToolStripMenuItem

发布于 2024-11-04 21:37:42 字数 380 浏览 7 评论 0原文

我在运行时该条中有一个 ContextMenuStrip,我添加了一个 ToolStripMenuItem。我在 XtraGridView 的 MouseDown() 事件处理程序中添加了这个 ContextMenuStrip。同时,我为新插入的 ToolStripMenuItem 添加了事件处理程序。我已经为该 ToolStripMenuItem 编写了一个事件处理函数。我的应用程序问题是,当用户右键单击 XtraGridView 时,它会显示我在运行时添加的所需菜单。当我单击新添加的 ToolStripMenuItem 时,它会执行所需的事件处理函数,但是当我再次执行相同的过程时,事件处理函数会执行两次,依此类推...

有人能解决这个问题吗?

谢谢。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

动次打次papapa 2024-11-11 21:37:42

您可能正在 XtraGridView 的单击事件中订阅 Click 事件。每次引发 GridView 的单击事件都会导致您再次订阅单击事件处理程序,因此当用户实际单击 ToolStripMenuItem 时,所有处理程序都会被调用。

我建议将订阅代码移至其他地方。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文