我是一個使用Infragistics
的新手。我試圖將上下文菜單添加到UltraWinGrid
中的特定行/列,但我無法做到這一點。看起來像向網格添加上下文菜單很簡單,但將其添加到特定的行/列並不是直截了當的。你能告訴我如何做到這一點?向UltraWinGrid添加行特定的上下文菜單
回答
您可以向窗體添加上下文菜單或控制網格所在的位置,並且只在需要該菜單的行/單元格上的網格中單擊鼠標右鍵時才顯示該菜單。
下面是一個例子,雖然它不漂亮。
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();
}
}
}
你可以給樣品你正在嘗試說? – Aanandi 2011-05-20 20:51:22
有幫助嗎?讓我知道是否需要更多解釋。 – 2011-05-24 21:03:53
MouseDown不起作用。請使用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();
}
}
}
}
}
MouseDown不起作用。請使用MouseUp。 – user6348094 2016-05-17 22:57:06
請檢查此[URL](http://stackoverflow.com/help)它將有助於提高您的內容質量 – 2016-05-17 23:20:22
- 1. 將子菜單添加到上下文菜單條的特定菜單項
- 2. 添加菜單上下文菜單
- 3. 只爲特定文件類型添加菜單項到windows上下文菜單
- 4. 上下文菜單的特定文件
- 5. 向elFinder添加自定義上下文菜單項
- 6. 向WPF RichTextBox上下文菜單添加自定義選項
- 7. 通過註冊表向特定擴展添加上下文菜單項
- 8. 將自定義菜單項添加到Finder上下文菜單
- 9. 擴展特定的上下文菜單
- 10. 添加上下文菜單.config文件
- 11. 如何添加上下文菜單中的甘特圖
- 12. 如何將上下文菜單添加到一個特定的文件
- 13. 將上下文菜單添加到UIImageView
- 14. 在Datagrid中添加上下文菜單
- 15. 從上下文菜單中選擇特定的菜單項
- 16. 將菜單項添加到默認的上下文菜單
- 17. 是否可以向聯繫人添加上下文菜單?
- 18. 向WP8瀏覽器控件添加上下文菜單
- 19. 向代碼控制器添加上下文敏感菜單
- 20. 將程序的特定功能添加到Windows上下文菜單
- 21. 在Eclipse的上下文菜單中添加行分隔符
- 22. 將菜單項添加到上下文菜單
- 23. 將菜單項添加到上下文菜單在VS2008 DSL
- 24. 在Windows上下文菜單中添加子菜單
- 25. 添加描述性菜單項到WPF上下文菜單
- 26. 向下箭頭添加標籤菜單
- 27. 向select2下拉菜單添加標題
- 28. 加入上下文菜單
- 29. GTK:定位上下文菜單項w.r.t上下文菜單
- 30. 如何添加在上下文菜單中添加更多菜單?
你可以閱讀下面的文章http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.2/CLR2.0/html/WinGrid_Using_the_WinGrid_ClickCell_Event_to_Show_a_Context_Menu.html – serhio 2013-03-15 14:23:49