共用方式為


SPField.ReadOnlyField property

取得或設定 Boolean 值,以指定是否可以修改欄位值。

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

Syntax

'宣告
Public Property ReadOnlyField As Boolean
    Get
    Set
'用途
Dim instance As SPField
Dim value As Boolean

value = instance.ReadOnlyField

instance.ReadOnlyField = value
public bool ReadOnlyField { get; set; }

Property value

Type: System.Boolean
若要指定的欄位無法修改 ; true否則,請false。

Examples

下列程式碼範例會讓欄位成為唯讀的根網站上指定清單中。

Using oSiteCollection As New SPSite("http://MyServer")
    Using oWebsite As SPWeb = oSiteCollection.OpenWeb()
        Dim oList As SPList = oWebsite.Lists("MyList")
        Dim oItem As SPListItem = oList.Items(0)
        oItem.Fields("MyField").ReadOnlyField = True
        oItem.Fields("MyField").Update()
    End Using
End Using
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;
        oItem.Fields["MyField"].Update();
    }
}
注意事項注意事項

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.

請參閱

參照

SPField class

SPField members

Microsoft.SharePoint namespace