SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to change a column type from multiline text to HTML.

I tried this:

string urlRoot = ConfigurationManager.AppSettings["url"].ToString();
SPSite site = new SPSite(urlRoot);
SPList list = site.RootWeb.Lists["Agenda"];
HtmlField htmlField = new HtmlField(list.Fields, "HTML", "NewHTMLField");
SPField fieldInContentType = list.ContentTypes["Agenda"].Fields["Body Intro"];
fieldInContentType = htmlField;

But I got the following exception:

Value does not fall within the expected range

Is it possible to do this?

share|improve this question

migrated from Jul 24 '11 at 11:44

This question came from our site for professional and enthusiast programmers.

All you have to do is change the RichTextMode property for the existing multi-line text field as follows:

using (SPSite site = new SPSite("http://sharepointdev:9000"))
    SPList list = site.RootWeb.Lists.TryGetList("List1");
    SPFieldMultiLineText fld = list.Fields["MultiText1"] as SPFieldMultiLineText;
    fld.RichText = true;
    fld.RichTextMode = SPRichTextMode.FullHtml;

Should do the trick.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.