SharePoint Lists: Creating Multiline Text Columns

Author by Mark Rentmeester

Programmatically creating columns (or fields) for a custom SharePoint list is fairly straight forward (Psuedo-code here):

SPList.Fields.Add("Field Name", SPFieldType, Required);

Creating a multiline text field column can also be fairly straight forward too (actual code here):

MyList.Fields.Add("My Multiline Column", SPFieldType.Note, true);

This will create a plain text multiline column which its contents are required. Question is: How do we create a multiline text column with the Rich Text or Enhanced Rich Text option? The way we do this is by creating the column schema with XML. To create a plain text, rich text, or enhanced rich text xml schema, choose the following path:

    • Plain Text Schema:
      string FieldXML = "";
    • Rich Text Schema:
      string FieldXML = "";
    • Enhanced Rich Text Schema:
      string FieldXML = "";

The key parts here are inserting the RichText, and RichTextMode properties when appropriate. So, to use this XML schema, we do the following:

list.Fields.AddFieldAsXml(FieldXML, true, SPAddFieldOptions.Default);

This will add our new field utilizing our XML schema, insert it into the default view, and use the Default options for the the other field properties. This article was originally written by Jordan Laik. It is moderated currently by Mark Rentmeester.


Mark Rentmeester

Director of Application Development Services