I saw some similar posts on this topic, but nothing that had a solution. Basically, I want to do the same thing as this poster here: http://news.infragistics.com/forums/p/13482/50108.aspx#50108
I see the same options in the context menu as he does.
What I want to do is only for some columns, I want to have my own context menu for those columns. Conditionally, on a cell by cell basis I want to have no context menu there, or a context menu with no items. But basically, I need to have a way to update the context menu right before it is about to get show to hide/show context menu items.
For other columns, I want to leave the default context menu in there.
Can this be done?
No control I know of allows you to specify a context menu on a single part of the control. What you have to do is apply the ContextMenu to the entire control and dynamically change it as the position of the mouse changes. So you would use the MouseMove event and trap where the mouse is and what it is over and change the ContextMenu based on that.
Here are some articles that show you how to tell what part of the grid the mouse is currently over:
HOWTO:UltraWinGrid Mouse Position and Cell Identification
HOWTO:UltraWinGrid Mouse Position and Column Identification
HOWTO:UltraWinGrid Mouse Position and Row Identification
I can figure out what cell I am in and show my context menu as long as the cell is not yet in edit mode.
If the cell is in edit mode, I am unable to override the context menu it is using to show my own.
It seems reasonable to want different columns to have different context menu options.
Hi,
Well, I would have thought that setting the ContextMenu on the grid control is picked up by the child controls - so that would work for cells in edit mode. If that doesn't work, then you probably need to assign a ContextMenu to the child TextBox control of the grid. You can use grid.ChildControls[0] to get the child control, if there is one, and then assign a ContextMenu to that.
Assigning the context menu strip on the grid itself does not work for the cell in edit mode. Also, there is no ChildControls property of the grid or the cell (using 8.2).
Thanks, that was it.
Sorry, it's Controls not ChildControls. :)