This is the code I wrote to reorder fields in a custom content type:

//get the content type
SPContentType listContentType = myList.ContentTypes[MyContentTypeName];
//get the field name to put first
string firstFieldName = myList.Fields[FirstFieldDisplayName].InternalName;
//get all field names in the content type
List<string> fieldNames = listContentType.FieldLinks
                                .Select(a => a.Name).ToList<string>();
//reorder field names
if (fieldNames.Remove(firstFieldName))
    fieldNames.Insert(0, firstFieldName);

I stepped through this code using a debugger and I see that the fieldNames list is used correctly - the correct field is removed and then inserted to the start of the list and the Reorder() is executed. Yet the new and edit form shows the fields in the original order. Please help.

  • @vitule: Just checked some old code of mine and it's essentially the same so not sure why this isn't working...
    – Alex Angas
    Commented Apr 8, 2010 at 0:22
  • I tried the code example above and it works for me too. Just out of interest, can you change the order of columns ok using the browser UI?
    – Paul Lucas
    Commented Apr 8, 2010 at 17:13

1 Answer 1


So, turns out that the field I'm trying to move was causing some issues when moved to the very first position. It's a custom field derived from SPLookup and I was getting an exception thrown from inside SPLookup when I moved the field to the first position using the UI. Everything was fine when I moved it to the second position, below the "Title" field. I spent an hour trying to figure out what the SPLookup exception meant but didn't figure it out and had to move on.

Anyway, I modified the above code by replacing the line

fieldNames.Insert(0, firstFieldName);


fieldNames.Insert(fieldNames.IndexOf("Title") + 1, firstFieldName);

Good enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.