...using Infragistics2.Win.UltraWinGrid.v9.2
The online documentation only says "true if the action completed successfully, false if the action failed."
I have users periodically reporting the error"Selection related properties(SelText, SelStart and SelLength) are not supported while the cell is not in edit mode". This code has run for years and it's my first time seeing this error. I went ahead and added if() blocks around the calls to PerformAction and swallowed the error just in case. So its handled, but what would cause the call to PerformAction fail?
/// <remarks> /// This method ensures the cursor remains at the end of the cell text if the user switches to another application /// while entering a note and then switches back. /// </remarks> private void NotesGrid_GotFocus(object sender, EventArgs e) {
.....
MoveCursorToEndOfCell(subjectCell)
}
private void MoveCursorToEndOfCell(UltraGridCell cell) { NotesGrid.PerformAction(UltraGridAction.ExitEditMode); NotesGrid.PerformAction(UltraGridAction.EnterEditMode); cell.SelStart = cell.Text.Length;}
Hello Kevin,
Have you been able to resolve your issue ? If you still have any concerns or questions I will be glad to help. If you need any additional assistance don’t hesitate to ask.
Regards
Hi Kevin,
It seems like you are paraphrasing the error message, but that looks like a very familiar Exception message that occurs when something tries to select text inside a Text Editor while it is not in edit mode. If that's the case, then the return value from the PerformAction method isn't really relevant. There's a big difference between PerformAction returning that the action failed and getting an exception because someone tried to perform an invalid operation.
To answer your question, PerformAction can fail in any number of cases where the grid is not in a state where the action can be performed. Why some failed actions raise an exception and others fail silently and return false is a much more complicated question. It depends a lot on the internal needs of the control.
Remember that PerformAction simulates user interaction with the control. So as much as possible, when you press a key to perform an action on the grid, the grid calls the exact same code as if you used PerformAction to do the same thing. Take the Tab key, for example. If you are in the last cell of the grid and press Tab, there's nowhere to go, but you certainly wouldn't want an exception to be raised in this case. So the PerformAction method just returns false.
In this case, you are using PerformAction to perform actions that the user could do using the F2 key. You exit and then immediately re-enter edit mode. These actions are probably working just fine. But when the cell is entering edit mode, internally, the grid is trying to select all of the text in the cell and for some reason, the cell is not in edit mode at that time.
This could be because of a timing issue. If you application is using DoEvents, or threads this can happen.Or it could be that your code is trying to enter Edit mode at a time when it's not possible to do so. In such a case, the grid should be smart enough to know that it failed and not select text, but you are using a pretty old version and it might be a bug that has since been fixed.
If you could give us the whole call stack, it might help us narrow down what's going on there, and we might be able to suggest a potential workaround.
But I think your best bet would be to try updating to the latest service release (in case this is already fixed) or to upgrade to the latest version of the controls.
How to get the latest service release - Infragistics Community
Hello Georgi,
I've never actually been able to produce the error myself, but I did receive the following screen shot from a user and, assuming their memory was correct, they were at a point where the code would activate a tab that contains a single control, the UltraGrid. That Grid has that OnFocus event that eventually makes a call to PerformAction method... it is intended to place the user's cursor into a cell and force it into edit mode so they can just start typing.
image here https://skydrive.live.com/redir?resid=57BD806B25C63EDE!118&authkey=!ADWFBSaZgtN3Zxc
I was not able to reproduce your issue, but if you have a sample that reproduce it, I`ll be glad to take a look.
Looking at the information from your post, maybe one possible reason for this issue, could be if you have not Active/Selected cell. Maybe will be better to include If conditions and check for ActiveCell.
Please send us more details about your scenario / sample and I`ll try to help you. If you have any questions, feel free to write me