Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当右击时,上下文菜单将出现在空白区域以及超级网格头上。_C#_Contextmenu_Infragistics_Ultrawingrid - Fatal编程技术网

C# 当右击时,上下文菜单将出现在空白区域以及超级网格头上。

C# 当右击时,上下文菜单将出现在空白区域以及超级网格头上。,c#,contextmenu,infragistics,ultrawingrid,C#,Contextmenu,Infragistics,Ultrawingrid,右键单击Ultragrid(Infrastics)的空白部分或C#上下文菜单中的标题会出现,并且不会执行任何操作。当单击落在一行上时,我如何才能仅显示关联菜单 所以我正在做一个项目,我有一个超网格,我在其中放了一个上下文菜单,当有人在网格中右键单击时,菜单就会出现(删除)。但是当右键单击时,上下文菜单出现在空白区域上,并且在超级网格头上出现,当单击一行时,我希望它出现。 这需要在您的环境中进行测试,但我认为它可以工作。 诀窍在于使用MouseDown事件检查鼠标位置下的单元格(如果有),并且仅当

右键单击Ultragrid(Infrastics)的空白部分或C#上下文菜单中的标题会出现,并且不会执行任何操作。当单击落在一行上时,我如何才能仅显示关联菜单


所以我正在做一个项目,我有一个超网格,我在其中放了一个上下文菜单,当有人在网格中右键单击时,菜单就会出现(删除)。但是当右键单击时,上下文菜单出现在空白区域上,并且在超级网格头上出现,当单击一行时,我希望它出现。

这需要在您的环境中进行测试,但我认为它可以工作。 诀窍在于使用MouseDown事件检查鼠标位置下的单元格(如果有),并且仅当我们在测试IsDataRow属性的DataRow单元格上时才分配ContextMenu

private void grid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
    UltraGridCell currentCell = null;
    grid.ContextMenu = null;

    if (e.Button == MouseButtons.Right)
    {
        Point ulPoint = new Point(e.X, e.Y);
        UIElement el = grid.DisplayLayout.UIElement.ElementFromPoint(ulPoint); 
        if (el != null)
            currentcell = (UltraGridCell)el.GetContext(typeof(UltraGridCell)); 
        if (currentcell != null && currentCell.Row.IsDataRow == true)
        {
            grid.ActiveCell = currentcell;
            grid.ContextMenu = menuPopup;
        }
    }
}

你能补充一些进一步的信息吗?就目前情况而言,人们可能很难帮助你……你有什么可以包含的代码吗?