The following is updated code from Ton Stegeman and it works.

 private static void AddContentType(SPWeb web, SPList spList, string ctName)
        if (web.AvailableContentTypes[(ctName)] != null)
            SPContentType ContentType = web.AvailableContentTypes[ctName];
            spList.ContentTypesEnabled = true;

            SPFolder rootFolder = spList.RootFolder;
            SPContentType ct = spList.ContentTypes[ctName];
            List<SPContentType> defaultCT = new List<SPContentType>();

  • Beware other readers: this removes all content types from the New Menu except the one specified in the method's argument. – James Love May 31 '11 at 18:03
  • What is the question? – Dan Henderson Mar 10 '17 at 19:55

Here's some utility code I use to reorder content types:

private void ReorderContentTypes(SPWeb web, string listName, string firstContentTypeName)
        SPList list = web.Lists[listName];

        SPContentType cType = web.AvailableContentTypes[firstContentTypeName];

        List<SPContentType> oldCTypes = new List<SPContentType>();

        for (int i = list.ContentTypes.Count -1; i >= 0; i--)
            if (!list.ContentTypes[i].Id.IsChildOf(cType.Id))


        foreach (SPContentType c in oldCTypes)

  • No, List<SPContentType> oldCTypes = new List<SPContentType>(); creates a new List (read: a collection) of SPContentTypes called oldCTypes. SPList is not involved on this particular line of code. – James Love May 31 '11 at 16:16
  • I need to keep the existing CTs. So your code wont work as you are deleting CTs. I just need to make customCT default and number 1 in order. – Robert G May 31 '11 at 16:48
  • My code re-adds them. Look at the foreach. – James Love May 31 '11 at 17:34
  • Perfect, just what i needed. – Anders Aune Oct 6 '11 at 8:17

You can specify the order of the content types in the SPFolder.UniqueContentTypeOrder property of the root folder (SPList.RootFolder).


  • You can only "get" that property, it's read only. – James Love May 31 '11 at 14:53
  • yes, but maybe with UniqueContentTypeOrder property – Matthias May 31 '11 at 15:12
  • You'd still have to build a List of ContentTypes and assign it to that property. I had issues with that, which is why I went with the method of deleting all the content types except the desired one for the default, adding them to a new list, and then re-adding them to the list's content types. – James Love May 31 '11 at 15:22
  • What's the matter of building a list of ContentTypes? What issues did you have? – Matthias May 31 '11 at 15:26
  • Building the list of content types was easy, it was assigning it to UniqueContentTypeOrder, can't remember the issues I had but I reverted to the method I posted above. – James Love May 31 '11 at 15:32

This might be of use:


I was trying to control what was shown in the menu, but I was also defining the order (in the solution I was building), and what was in the list, and then assigning it to the UniqueContentTypeOrder.

I found that when trying to set the UniqueContentTypeOrder, you need to use SPList.ContentTypes to get the content type to set in the UniqueContentTypeOrder list, and not use one from the SPWeb.ContentTypes collection. If you use the SPWeb one I found you got an ArgumentOutOfRangeException.

  • I think that was the issue I had, if you look at my code I'm getting SPWeb.AvailableContentTypes. I then also check for IsChildOf, because List ContentTypes are children of the respective Site ContentTypes. – James Love May 31 '11 at 15:45
  • FWIW: I voted this up, as it's a proper solution, and probably the way you're meant to do it, along with useful advice about where to get your contenttypes in the first place. Who voted this down and why? – James Love May 31 '11 at 17:38
  • Maybe because it doesn't address just the ordering issue, but also what was on the list - it makes it a little less obvious? Or parhaps 'cos I didn't include all the code in here? There didn't seem much point repeating it all. Thanks for the vote though James! FWIW, it worked for me. – Andy Burns Jun 1 '11 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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