2 added 139 characters in body
source | link

I've explored another approach to this which uses the object model to set the ReadOnlyField property (see: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.readonlyfield.aspx).

SPList list = web.Lists["Your list name"];
SPField guideline = list.Fields["Guideline"];
guideline.ReadOnlyField = true;
guideline.Update();  

Once this has been done to a field, it will no longer show up on any forms including the new item and edit item forms. IfThe drawback here is when you ever neededadd new item to change the valuelist and you would havewant to set the initial value for the read-only column. You would need to change the value of the ReadOnlyField property back to false (presumably with code), changeadd the valueitem, then set the ReadOnlyField property back to true. The same process would be needed if changing the value of the read-only field. Furthermore, I tested to see what happens when you try to change the value through code with this property set to true. It does not generate any exceptions or errors, it simply discards the new value.

I've explored another approach to this which uses the object model to set the ReadOnlyField property (see: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.readonlyfield.aspx).

SPList list = web.Lists["Your list name"];
SPField guideline = list.Fields["Guideline"];
guideline.ReadOnlyField = true;
guideline.Update();  

Once this has been done to a field, it will no longer show up on any forms including the new item and edit item forms. If you ever needed to change the value you would have to set the ReadOnlyField property back to false (presumably with code), change the value, then set the property back to true. Furthermore, I tested to see what happens when you try to change the value through code with this property set to true. It does not generate any exceptions or errors, it simply discards the new value.

I've explored another approach to this which uses the object model to set the ReadOnlyField property (see: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.readonlyfield.aspx).

SPList list = web.Lists["Your list name"];
SPField guideline = list.Fields["Guideline"];
guideline.ReadOnlyField = true;
guideline.Update();  

Once this has been done to a field, it will no longer show up the new item and edit item forms. The drawback here is when you add new item to the list and you want to set the initial value for the read-only column. You would need to change the value of the ReadOnlyField property back to false, add the item, then set the ReadOnlyField property back to true. The same process would be needed if changing the value of the read-only field. Furthermore, I tested to see what happens when you try to change the value through code with this property set to true. It does not generate any exceptions or errors, it simply discards the new value.

1
source | link

I've explored another approach to this which uses the object model to set the ReadOnlyField property (see: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.readonlyfield.aspx).

SPList list = web.Lists["Your list name"];
SPField guideline = list.Fields["Guideline"];
guideline.ReadOnlyField = true;
guideline.Update();  

Once this has been done to a field, it will no longer show up on any forms including the new item and edit item forms. If you ever needed to change the value you would have to set the ReadOnlyField property back to false (presumably with code), change the value, then set the property back to true. Furthermore, I tested to see what happens when you try to change the value through code with this property set to true. It does not generate any exceptions or errors, it simply discards the new value.