Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
why would UltraGrid.PerformAction fail
posted

...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;
}