Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Hidden Property

SPContentType.Hidden Property

Windows SharePoint Services 3

Gets or sets whether the content type is hidden on the list’s New menu.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public bool Hidden { get; set; }

Property Value

Type: System.Boolean
true if the content type is hidden on the list’s New menu; otherwise false.

ExceptionCondition
SPContentTypeReadOnlyException

The value of the ReadOnly property is true.

SPContentTypeSealedException

The value of the Sealed property is true.

You can use this property to specify that a content type be hidden. Hidden content types are not displayed on the New menu for list views. Therefore, users cannot create new items of that content type from the list. The content type is still displayed everywhere else in the user interface.

TipTip

To change the order in which content types appear on the New menu, set the UniqueContentTypeOrder property.

When you modify the value of this property, your change does not take effect until you call the Update() method. Calling this method commits all modifications to the content type definition back to the SharePoint database.

The following console application prevents one of the content types available in a document library from appearing on the library’s New menu.

using System;
using Microsoft.SharePoint;

namespace Test
{
    class ConsoleApp
    {
        static void Main(string[] args)
        {
            Console.WriteLine();
            SPSite oSPSite = new SPSite("http://localhost");
            SPWeb oSPWeb = oSPSite.OpenWeb();

            // Hide a content type from the New menu on a list.
            SPList oList = oSPWeb.Lists["Custom Document Library"];
            SPContentType oContentType = oList.ContentTypes["Content Type Name"];
            if (oContentType.ReadOnly || oContentType.Sealed)
            {
                Console.WriteLine("Content type cannot be modified.");
            }
            else
            {
                oContentType.Hidden = true;
                oContentType.Update();
                Console.WriteLine("Content type is now hidden.");
            }

            oSPWeb.Dispose();
            oSPSite.Dispose();

            Console.WriteLine();
            Console.Write("Press ENTER to continue...");
            Console.ReadLine();
        }
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft