我是新手,正在使用Infragistics
. 我正在尝试将上下文菜单添加到 中的特定行/列UltraWinGrid
,但我无法做到。看起来将上下文菜单添加到网格很简单,但将其添加到特定的行/列并不简单。你能告诉我怎么做吗?
问问题
4223 次
2 回答
3
您可以将上下文菜单添加到表单或控制您的网格将驻留在其中,并且仅当他们在网格中右键单击需要该菜单的行/单元格时才显示它。
这是一个例子,虽然它并不漂亮。
private void UltraGrid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenu.Hide();
Point point = new System.Drawing.Point(e.X, e.Y);
UIElement uiElement = ((UltraGridBase) sender).DisplayLayout.UIElement.ElementFromPoint(point);
UltraGridCell cell = (UltraGridCell) uiElement.GetContext(typeof (UltraGridCell));
if (cell != null && UseThisContextMenu(cell))
{
ContextMenu.Show();
}
}
}
于 2011-05-13T13:04:27.560 回答
0
鼠标按下不起作用。请使用 MouseUp。
private void UltraGrid1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Point point = new System.Drawing.Point(e.X, e.Y);
UIElement uiElement = ((UltraGridBase)sender).DisplayLayout.UIElement.ElementFromPoint(point);
UltraGridCell cell = (UltraGridCell)uiElement.GetContext(typeof(UltraGridCell));
if (cell.Band.Index == 0)
{
if (cell.Column.Key.Equals("ColumnToShow"))
{
contextMenuStrip.Show();
}
else
{
contextMenuStrip.Hide();
}
}
}
}
}
于 2016-05-17T22:55:57.230 回答