Is there any way by which I can remove anchors of a shape added in spreadsheetgear. So that the user cannot change the size of the shape. Please Suggest a solution or any work around.
2 Answers
You could enable worksheet protection on the sheet that contains the shapes you want to lock. This involves using one of the following:
- IWorksheet.ProtectContents - set to true
- IWorksheet.Protect(...) - enables ProtectContents but also requires a password to unprotect (using the IWorksheet.Unprotect(...) method)
You will also need to ensure that your IShape's Locked property is also set to true. Otherwise, this protection mechanism will not be enforced for your shapes. Note that this feature will disable more than just changing the size of a shape--it basically locks out any modification of the shape.
Also note that this protection mechanism will also disable many other modifying capabilities for your worksheet, such as editing cells whose IRange.Locked property is set to true, resizing row/column headers, modifying AutoFilter options, etc.

- 3,014
- 1
- 15
- 11
-
In short you can say that it will lock every thing on my sheet, as I have tried it as well. Actually I am creating a prototype in which I was supposed to read the borders of cell as lines(top, left, height and width). So I decided to draw a line instead of border so that it could be easy to read it. But the mentioned problem is there with lines. Although with your previous help I am able to do a lot with spreadsheetgear, so thanks for your help. – Ammar Oct 31 '14 at 05:06
A workaround has been found from this link. I added an event of workbook which is available with the name ShapeSelectionChanging
. A single line of code e.Cancel = True
worked for it. But still a problem is that the anchors are being shown for a while. Tell me if anyone have any suggestion.