我是一個使用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. 只爲特定文件類型添加菜單項到windows上下文菜單
- 2. 向WPF RichTextBox上下文菜單添加自定義選項
- 3. 通過註冊表向特定擴展添加上下文菜單項
- 4. 如何添加上下文菜單中的甘特圖
- 5. 如何將上下文菜單添加到一個特定的文件
- 6. 在Datagrid中添加上下文菜單
- 7. 將菜單項添加到默認的上下文菜單
- 8. 向代碼控制器添加上下文敏感菜單
- 9. 向WP8瀏覽器控件添加上下文菜單
- 10. 將菜單項添加到上下文菜單在VS2008 DSL
- 11. 在Windows上下文菜單中添加子菜單
- 12. 向下箭頭添加標籤菜單
- 13. 向select2下拉菜單添加標題
- 14. 加入上下文菜單
- 15. GTK:定位上下文菜單項w.r.t上下文菜單
- 16. 定位上下文菜單
- 17. 如何在上下文菜單的特定位置添加較低級別的子菜單?
- 18. Handsontable添加評論到自定義上下文菜單
- 19. 在C#中運行時添加上下文菜單條
- 20. Sitecore:更改特定項目下項目的上下文菜單?
- 21. 添加上下文菜單VS 2010上加載負荷
- 22. QTableWidget - 僅用於特定單元格/列的上下文菜單
- 23. 指定與特定選項的上下文菜單 - 合併
- 24. 上下文菜單中特定項目的選定索引
- 25. 更改一個特定上下文菜單項的文本
- 26. Infragistics UltraWinGrid選擇新添加的行
- 27. 使用特定模板時將下拉菜單添加到引導菜單
- 28. 在運行時將項目添加到數據綁定上下文菜單
- 29. 在tinyMCE的上下文菜單中添加「文本顏色」
- 30. Webdriver - 在特定座標下打開上下文菜單
你可以閱讀下面的文章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