NativeExcel for .Net Developer's Reference

IRange.Locked Property

Gets or sets a value that indicates whether the cell is locked. If the cell is not locked it can be modified when the sheet is protected.

[Visual Basic]
PropertyLockedAsBoolean
[C#]
boolLocked{get;set;}
[C++]
__propertyboolget_Locked();
__propertyvoidset_Locked(bool);
[JScript]
functiongetLocked():bool
functionsetLocked(bool);

Property Value

true if the cell is locked, false if the cell can be modified when the sheet is protected. Default value is true.

Example

This example unlocks cells B5:F30 on sheet one so that they can be modified when the sheet is protected.

[C#]
 IRange r = book.Worksheets[1].Range["B5:F30"]; 
 r.Locked = false;
 book.Worksheets[1].Protect();
[VisualBasic]
 Dim r As IRange = book.Worksheets(1).Range("B5:F30")
 r.Locked = False
 book.Worksheets(1).Protect()
[C++]
 IRange* r = book->Worksheets->Item[1]->Range->Item[S"B5:F30"]; 
 r->Locked = false;
 book->Worksheets->Protect();

See Also

IRange Interface | NativeExcel Namespace