I have a hierarchical grid with two child bands attached to a parent band.
Each level needs a different context menu. Any way to, on row click, change the ContextMenuUltra to a different PopupMenuTool?
The other option that would be ok would be for us to be able to hide just that popup menu's instance of certain tool items (we would disable the main toolbars instead of hide them)
You could do either...I wasn't sure which event you were referring to, but typically one handles MouseDown and configures a context menu (or PopupMenuTool) based on the entity at the current cursor position, so that when it is displayed on the MouseUp, it has the appropriate menu items. In the following example, the menu is changed based on the band in which the row at the current cursor position resides:
this.ultraGrid1.MouseDown += new MouseEventHandler(ultraGrid1_MouseDown);void ultraGrid1_MouseDown(object sender, MouseEventArgs e){ // Get the UltraGridRow at the current cursor position UltraGrid grid = sender as UltraGrid; UIElement controlElement = grid.DisplayLayout.UIElement; UIElement elementAtPoint = controlElement.ElementFromPoint( e.Location ); if ( elementAtPoint != null ) { UltraGridRow rowAtPoint = elementAtPoint.GetContext( typeof(UltraGridRow) ) as UltraGridRow; if ( rowAtPoint != null ) { UltraGridBand band = rowAtPoint.Band;
// Assuming a different PopupMenuTool is defined for each band... string menuKey = band.Index == 0 ? "bandZero" : band.Index == 1 ? "bandOne" : "bandTwo"; this.ultraToolbarsManager1.SetContextMenuUltra( grid, menuKey ); } }
}
Excellent. That was exactly what I needed: the line of code I was looking for was this:
this.ultraToolbarsManager1.SetContextMenuUltra( grid, menuKey );
I was looking at it from the wrong direction.
I assumed that I set something in the grid to the a context menu, not the other way around.
But it makes sense now. TY!