I have a column that we will call C. This Column is associated to a Content Type (CT).
If I go to the properties of the CT -> Column C I can set the column to be Facoltative or Hidden:
If I put it to Hidden I cannot see it at All, if I set it to Facoltative I see it in the New Form.
The problem I'm facing is I want that field displayed only in Display Mode (neither in Edit or New).
I tried code like this:
var ct = web.ContentTypes["CT"]; ct.Fields["C"].ShowInEditForm = false; ct.Fields["C"].ShowInNewForm = false; ct.Fields["C"].ShowInDisplayForm = true; ct.Fields["C"].ShowInViewForms = true; ct.Update(true); SPField rag = web.Fields.GetFieldByInternalName("C"); rag.ShowInEditForm = false; rag.ShowInNewForm = false; rag.ShowInDisplayForm = true; rag.ShowInViewForms = true; rag.Update(true);
but even if this works for other fields, for this it isn't working. It displays me the field in View, it doesn't in Edit but in New the column "C" is showed!
Can anybody help me? I'm trying and retrying but I cannot understand WHY it continues to show me in the new form this damned column!
Thank you very much
EDIT: the code posted above works for new list but NOT for the old one. How can I update the old one? I tried to fix every single list acting on the SPList.Fields and SPList.ContentType but doesn't works as expected! P.S.: I configure some parameters from the UI for the visibility of the fields..