Removing objects from the SharePoint ribbon

If we need to remove a button from the SharePoint ribbon we can easily achieve this by creating a feature that defines a custom action. The feature should just refer to the element manifest, as follows.

<Feature xmlns=""
         Title="3 Guys On SharePoint Ribbon Customisations"
         Description="Makes changes to the ribbon to match the 3 Guys On SharePoint requirements"
    <ElementManifest Location="RibbonCustomisations\Elements.xml" />

The element manifest file then needs to define a custom action, referring to the location of the ribbon tab, group or control that you wish to remove.

        <CustomAction Id="3GuysCustomAction.RemoveUsageNewItem"
                        <CommandUIDefinition Location="Ribbon.ListItem.New"/>
                        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.VersionHistory"/>
                        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.ManagePermissions"/>
                        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.DeleteItem"/>
                        <CommandUIDefinition Location="Ribbon.ListForm.Edit.Actions.DeleteItem"/>

In this example we are removing several controls from various locations. The ‘New’ button is removed from the list; the ‘Version History’, ‘Manage Permissions’ and ‘Delete Item’ buttons are removed from the list item display form; and the ‘Delete Item’ is removed from the list item edit form. This is achieved by setting the Location attribute of the CommandUIDefinition element to the location(s) that we wish to remove. The default locations for the tabs, groups and controls can be found listed on MSDN.

Note that we can also remove groups (such as ‘Connect & Export’) or even whole tabs (for example the list tab) by specifying the locations of these rather than individual controls.

<CommandUIDefinition Location="Ribbon.List.Actions"/>
<CommandUIDefinition Location="Ribbon.List"/>

To prevent this customisation being deployed everywhere we restrict the removal to a single list type by setting the RegistrationId and RegistrationType attributes of the CustomAction element. In this instance we have a custom list definition with type 10004 so we set the RegistrationId =”10004″ and the RegistrationType=”List”. We also need to set the Location attribute of the CustomAction element to ‘CommandUI.Ribbon’, which tells SharePoint to apply the customisation everywhere for the specified RegistrationId. There are other options here:

CommandUI.Ribbon.ListView – Customization appears when the list view Web Part is present.
CommandUI.Ribbon.EditForm – Customization appears on the edit form.
CommandUI.Ribbon.NewForm – Customization appears on the new form.
CommandUI.Ribbon.DisplayForm – Customization appears on the display form.

Of course if required you can also manipulate the ribbon programmatically. Simply get a reference to the current SPRibbon object by passing in a reference to the current Page object.

            // Gets the current instance of the ribbon on the page.
            SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);

            // Make sure the ribbon exists
            if (ribbon != null)

Note the call to the TrimById method, which takes the location of the tab, group or control as a parameter – this is actually declared as a method on the Ribbon object in the Microsoft.Web.CommandUI assembly, which SPRibbon inherits from. To use this method successfully and build your project you will need to add a reference to the Microsoft.Web.CommandUI assembly, found in the SharePoint Root\ISAPI folder.


MSDN – Server Ribbon XML

MSDN – Default Server Ribbon Customization Locations

MSDN – SPRibbon class

MSDN – Ribbon.TrimById Method (String)

This entry was posted in SharePoint, SharePoint 2010 and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>