ReadOnlyField property
Collapse the table of content
Expand the table of content

SPField.ReadOnlyField property

Gets or sets a Boolean value that specifies whether values in the field can be modified.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public bool ReadOnlyField { get; set; }

Property value

Type: System.Boolean
true to specify that the field cannot be modified; otherwise, false.

The following code example makes a field read-only in a specified list on a root Web site.

using (SPSite oSiteCollection = new SPSite("http://MyServer"))
    using (SPWeb oWebsite = oSiteCollection.OpenWeb())
        SPList oList = oWebsite.Lists["MyList"];
        SPListItem oItem = oList.Items[0];
        oItem.Fields["MyField"].ReadOnlyField = true;

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

© 2015 Microsoft