在 XtraGridview 控件中显示 ContextMenuStrip 时出现问题

发布于 2024-11-06 01:51:36 字数 333 浏览 8 评论 0原文

我有一个 ContextMenustrip & DevExpress XtraGridView。当用户右键单击 XtraGridView 时,我向用户显示了 ContextMenustrip,为此我使用了 XtraGridView 的 MouseDown() 事件。此应用程序的问题是,当我的 gridview 包含最少行时,它会在 Gridview 末尾显示一些空白空间。当用户右键单击 gridview 时,我不想在 XtraGridView 的空白区域中显示 ContextMenustrip。我只想仅在选定的行位置显示 ContextMenustrip。 这样是否可以避免这个问题呢?

谢谢..

I'm having one ContextMenustrip & DevExpress XtraGridView. And i shown the ContextMenustrip to the user when user right clicks on the XtraGridView, for that i used XtraGridView's MouseDown() event. Issue of this application is that when my gridview contains minimum rows then it shows the some empty space at the end of the Gridview. And i don't want to show the ContextMenustrip in that empty space of the XtraGridView when user right click on the gridview. I just want to show the ContextMenustrip at selected row position only.
Is this possible to avoid this problem?

thanks..

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

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

发布评论

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

评论(1

感性不性感 2024-11-13 01:51:36

我建议您使用稍微不同的方法。处理 GridView 的 PopupMenuShowing 事件,如下所示,以确保菜单仅在打开时打开必要的。

private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) {
            if(e.HitInfo.HitTest ==  GridHitTest.RowCell)    {
                e.Allow == false;
                // your code to show menu
            }
        }

I would suggest that you use slightly different approach. Handle the GridView's PopupMenuShowing event as shown below to make certain that your menu is open only when it is necessary.

private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) {
            if(e.HitInfo.HitTest ==  GridHitTest.RowCell)    {
                e.Allow == false;
                // your code to show menu
            }
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文