On my UltraGrid (v14.2), I have AllowMultiCellOperations turned on. I've selected several cells that are not adjacent to one another, and am trying to paste the same single value into all of them. However, I get the following error:
"Error performing Paste operation. Further information: Invalid selection. The selection must be rectangular. "
Is there some way to go about supporting non-adjacent multicell pasting?
Understood. Thanks!
Is there a good way to prevent the user from doing such a paste (while still allowing a rectangular selection paste)?
Also, if I make the individual cell selections in a single column (or row) and try to paste, I don't get an error but do get strange results. If I should create a new post for this question, please let me know.
For example, I've selected alternating cells in Column 0 and am attempting to paste '12345' in.
I don't get the "The selection must be rectangular." error. The data actually pastes, but not to the correct cells. It starts with the top cell I selected, and then pastes to the X following cells, where X is the number of additional cells I had selected.
The same thing happens for cells selected across a row.
Adam Shelton said:Is there a good way to prevent the user from doing such a paste (while still allowing a rectangular selection paste)?
I'm a little uncertain what you mean by this. The grid is already stopping the user from pasting in this case. So I'm guessing you just don't want the grid to show the error message? The way to do that would be to handle the grid's Error event. You would check e.ErrorType and examine the properties of e.MultiCellOperationErrorInfo to identify the particular error. Then you can set e.Cancel to true to prevent the grid from showing the default error message.
Adam Shelton said:I don't get the "The selection must be rectangular." error. The data actually pastes, but not to the correct cells. It starts with the top cell I selected, and then pastes to the X following cells, where X is the number of additional cells I had selected.
What's happening here is that the grid is just pasting based on the first selected cell and ignoring the rest.
Mike Saltzman said:What's happening here is that the grid is just pasting based on the first selected cell and ignoring the rest.
Would this be considered a bug? I'd think that such a paste should either be:
No, this is the intended behavior. Since the grid cannot paste into a non-rectangular selection, it just uses the first cell as a reference.
You could cancel the paste operation in BeforeMultiCellOperation if you want to.