Hi,
We are experiencing an issue with cells having a input mask set on them. The default context menu does not show up when the cell is in edit mode and we right-click in it. The cell simply exit the edit mode.
This issue is happens if you have to following properties on the grid:
1. HeaderClickAction.SortMulti2. CellClickAction.Edit3. row selection type set to SelectType.Single
If row selection type is set to none, we do see the default context menu.
How can I make sure the menu will show up even if we have an input mask for the cell in edit mode?
Thanks,Annie
We are using .NetAdvantage 2009 vol.1
Hi Annie,
I tried this out with these settings, but I am unable to reproduce the issue you are describing. I can't see what the HeaderClickAction or SelectType on the row could possibly have to do with this. And CellClickAction of Edit is the default setting, so setting that explicitly doesn't do anything.
Perhaps you could post a small sample project here that demonstrates the issue?
Back to this issue, I have more details to provide.
For this particular grid, we are listening to the MouseUp event in order to display our custom context menu and we also listen to a custom event we created called "RowRightClick" which is raised within the ultragrid_click event. We get the row and cell information and check if the user used the right button of the mouse. If so, we raise this custom event. In this event, we set the current row as the selected one (row.Selected = true).
We get the problem mentioned above only when a cell has an input mask. Any other cells just works fine, i.e. the row gets selected and the appropriate context menu is displayed, depending if the cell is in edit mode or not.
For the column having an input mask set, right-clicking in the cell currently being edited simply exit the edit mode and displays our own context menu. Something is causing the cell to think it has to exit the editing mode but I am not sure what. Like I said, the cell next to this one is a regular one and if I go into edit mode and right click, I see the Cut, Copy, Paste... context menu. So what is different with a cell having an input mask?
As always, thanks for the input.
Annie
P.S. We are using version 9.2.20091.2085
Selecting and editing are mutually exclusive. Entering edit mode on any cell will clear the selection and selecting anything will exit edit mode. This is pretty standard, it's the same way Windows Explorer and the Windows Tree control behaves.
Hi again,
Any idea why doing the action of setting the row as selected causes the cell having an input mask to exit edit mode?
Thanks.Annie
Hi Mike,
I moved setting the ActiveRow in the MouseDown event and the context menu is shown within the MouseUp event.
What I have as an extra here is that within the grid's click event, I raise my own RowRightClick event which is trying to set the active row as the selected one.private void ultraGrid_Click(object sender, System.EventArgs e){Infragistics.Win.UIElement element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(m_lastMouseDownX, m_lastMouseDownY);UltraWinGrid.UltraGridRow row = null;UltraWinGrid.UltraGridCell cell = null;try{ row = GetRowFromPoint(element); //trigger either the RowClick or RowRightClick events if (row != null) { //get the cell that was clicked cell = (UltraWinGrid.UltraGridCell)element.GetContext(typeof(UltraWinGrid.UltraGridCell)); if (cell != null) { //create a brand new event argument Hashtable rowData = new Hashtable(); foreach (UltraWinGrid.UltraGridCell dataCell in row.Cells) { rowData.Add(dataCell.Column.Key, dataCell.Value); } OurRowEventArgs args = new OurRowEventArgs(row, row.Index, cell.Column.Key, cell.Value, cell.Text, rowData); if (m_lastMouseButtonClicked == MouseButtons.Left) OnRowClick(args); else if (m_lastMouseButtonClicked == MouseButtons.Right) OnRowRightClick(args); } } ...}}void m_gridTransLines_RowRightClick(object sender, OurRowEventArgs e){ e.Row.Selected = true;}Doing the action of setting the row as selected causes the cell having an input mask to exit edit mode instead of showing the default context menu. Problem is that I cannot set the active row as the selected one in the mouse down event because there are other scenarios where I do not want that. And I really need an input mask on this particular cell.
Using the Click event to show a context menu is probably not a good idea. If you try this out in windows and right-click on any application, you will find that a ContextMenu always shows in the MouseUp, not the MouseDown. So it's typically a good idea to use the MouseUp event.
If this is related to the other issue you posted about where you are getting the row using the grid's UIElements, then what I recommend is that you activate the row in the MouseDown event and then show the context menu in the MouseUp event. That way setting the ActiveRow does not have any effect on the context menu.