We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Disable keyboard copy/paste in griddesktop

Hi,
I want to disable the option to use ctrl-c, ctrl-x and ctrl-v in a griddesktop instance. I have set all the cells to protected, set ShowContextMenu to false and EnableClipboardCopyPaste to false but I can still use the keyboard shortcuts to cut/paste data into the cells. Is there a way to stop the paste?
Thanks, Zoe

@zoe.w,

Does it work in your desired way in MS Excel when you protect the sheet manually in it? Could you please share a sample WinForm application, zip the project and post us with resource files, we will check it soon.

Hi,

Yes, in Excel I see a popup message saying that the cell is protected when I try to paste using ctrl-v or cut using ctrl-x.

I can reproduce in your sample application by adding the following lines of code in the button click method in OpeningExcelFile.cs

gridDesktop1.Worksheets[0].Protected = true;
gridDesktop1.EnableClipboardCopyPaste = false;
gridDesktop1.EnableUndo = false;
Aspose.Cells.GridDesktop.CellRange range = gridDesktop1.Worksheets[0].CreateRange(0,0, gridDesktop1.Worksheets[0].ColumnsCount, gridDesktop1.Worksheets[0].RowsCount);
gridDesktop1.Worksheets[0].SetProtected(range, true);

I have attached a gif of the paste behaviour that i expected to be disabled. Editing the cells via double click or by F2 is disabled.

I also experienced a null reference exception and crash of the demo application if I try to paste (ctrl-V) into a cell that I previously cut (ctrl-X) from. I have attached a gif of that too.

excel protected.gif (402.4 KB)
desktop crash.gif (894.7 KB)

Thanks, Zoe

@zoe.w,

Thanks for the image files.

You are right. I confirmed, in MS Excel I see a popup message is displayed saying that the cell is protected when we try to paste using Ctrl-v or cut using Ctrl-x. In GridDesktop, I could not find a way to disable the option to use Ctrl-c, Ctrl-x and Ctrl-v. I have logged a ticket with an id “CELLSNET-50953” for your issue/requirements. We will investigate and look into the details of the issue/requirements.

Once we have an update on it, we will let you know.

1 Like

That’s great, thank-you.

@zoe.w,

You are welcome.

@zoe.w,

This is to inform you that your issue has been resolved. The fix will be included in the (upcoming) next release (Aspose.Cells for .NET v22.5), which is scheduled to be released in this week. You will also be notified when the next version is released.

The issues you have found earlier (filed as CELLSNET-50953) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi