de la propiedad SPField.ReadOnlyField
Obtiene o establece un valor booleano que especifica si se pueden modificar los valores del campo.
Espacio de nombres: Microsoft.SharePoint
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Property ReadOnlyField As Boolean
Get
Set
'Uso
Dim instance As SPField
Dim value As Boolean
value = instance.ReadOnlyField
instance.ReadOnlyField = value
public bool ReadOnlyField { get; set; }
Valor de propiedad
Tipo: System.Boolean
true para especificar que el campo no se puede modificar; en caso contrario, false.
Ejemplos
En el ejemplo de código siguiente se convierte en un campo de sólo lectura en una lista especificada en un sitio Web raíz.
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();
}
}
Nota
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.