Spread Windows Forms 9.0 Product Documentation
Locked Property (Cell)
Example 


Gets or sets whether a cell is marked as locked from editing.
Syntax
'Declaration
 
Public Property Locked As Boolean
'Usage
 
Dim instance As Cell
Dim value As Boolean
 
instance.Locked = value
 
value = instance.Locked
public bool Locked {get; set;}

Property Value

Boolean: true if marked as locked; false otherwise
Remarks

You can specify that a certain cell is locked; that is, the user cannot edit it. You mark a cell as locked by setting this property to true. Cells are not locked until the SheetView Protect property is also set to true for the sheet. Because the default value of the Protect property is true, unless you have changed the value of the Protect property, when you mark a cell as locked, it is locked and the user cannot edit it. When the Protect property is false, the user can still interact with a cell marked as locked.

Be aware that the setting for this property can be overridden if a named style is assigned to the cell using the StyleName property, and that named style sets the locked status.

Example
This example locks the cell to prevent the user from editing the contents of the cell and sets the horizontal and vertical alignment for the contents of the cell.
using FarPoint.Win.Spread;
using FarPoint.Win;

private void Form1_Load(object sender, System.EventArgs e)
{
     FarPoint.Win.Spread.Cell acell;
     acell = fpSpread1.ActiveSheet.Cells[0, 0];
     fpSpread1.ActiveSheet.Cells[0, 0].Text = "Alignment";
     acell.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Right;
     acell.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Top;
     acell.Locked = true;
     fpSpread1.ActiveSheet.Rows[0].Height = 80;
}
Imports FarPoint.Win.Spread
Imports FarPoint.Win

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     Dim acell As FarPoint.Win.Spread.Cell
     acell = FpSpread1.ActiveSheet.Cells(0, 0)
     FpSpread1.ActiveSheet.Cells(0, 0).Text = "Alignment"
     acell.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Right
     acell.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Top
     acell.Locked = True
     FpSpread1.ActiveSheet.Rows(0).Height = 80
End Sub
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

Cell Class
Cell Members
Protect Property

 

 


Copyright © GrapeCity, inc. All rights reserved.