SPField.ReadOnlyField 属性
获取或设置一个 Boolean 值,指定是否可以修改字段中的值。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
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; }
属性值
类型:System.Boolean
true指定无法修改字段 ;否则为false。
示例
下面的代码示例将一个字段在根网站上的指定列表中是只读的。
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.