Hi,
I have an UltraGrid that contains editable cells (AllowEdit=true on these columns). These cells get into edit mode via the MouseUp event (this is something that I must do because I also have drag/drop capabilities on this ultragrid that needs precedence, so I had to massage the code in order to get the cell into edit mode).
I also have code for the DoubleClickRow event, so that when the event fires, it tries to open a new Form based on data from that row.
With this combination, I notice that whenever I try to double click a row, and my mouse happens to be over an editable cell, it will put the cell into edit mode first (due to MouseUP), and then fire the double-click (due to DoubleClickRow). No problems here for me.
However, I notice that even though the double-click fires properly and opens a new form for me to look at, the cell on the UltraGrid still appears to be in edit mode (i.e. it has a blinking cursor in the cell and all or some of the text is highlighted, depending on where the user double-clicked in the cell).
I tried using PerformAction.ExitEditMode, but it doesn't seem to fully get the cell out of edit mode. What I mean is, when I run the debugger, I do notice that the ultragrid1.ActiveCell.IsInEditMode property changes to false after running PerformAction.ExitEditMode. But visually, it is still a cell with a blinking cursor and highlighted text. Any ideas how to get it to look normal again?
Example code:
private void ultragrid1_MouseUp(object sender, MouseEventArgs e)
{
//Put the UltraGridCell at the mousepoint into edit mode
UltraGridCell cellHitTest = GetCellHit();
ultragrid1.ActiveCell = cellHitTest;
ultragrid1.PerformAction(UltraGridAction.EnterEditMode);
}
private void ultragrid1_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
ultragrid1.PerformAction(UltraGridAction.ExitEditMode);
Nevermind, I found the root-cause of the problem. The problem was because of the order of operation of the events that were occurring as a result of double-clicking a row on an editable cell. Here's what happens in order:
1) ultragrid1_MouseDown
2) ultragrid1_MouseUp
3) ultragrid1_DoubleClickRow
4) ultragrid1_MouseUp
It is the 2nd MouseUp that causes it to go back into edit mode. So my fix for this was to add a simple boolean check in the MouseUp event to see if the DoubleClickRow event fired or not. If it did, then get the cell out of edit mode.
if (!bDoubleClickRowFired)
else
bDoubleClickRowFired = false;
bDoubleClickRowFired = true;