Thursday, March 15, 2012

How to modify the ribbon of the RichTextBox Control by a CustomAction

Hi guys,
I needed to hide some buttons of the RichTextBox’s ribbon.
The fastest and esiest way I've found is to create a CustomAction.
First of all we need to add an empty element to a sharepoint project.
After that we must modify the Elements.xml files to hide/customize the buttons.
This is mine:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
    Id="RemoveRibbonButton"
    Location="CommandUI.Ribbon">
        <CommandUIExtension>
            <CommandUIDefinitions>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.Fonts"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.FontSize"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.ClearFormat"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.Bold"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.Italics"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.Underline"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.Strikethrough"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.FontBackgroundColor"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Font.FontColor"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Styles.Styles"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Markup.ElementWithStyle"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Markup.LanguagesLabel"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Markup.SelectLabel"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Markup.HtmlLabel"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Markup.Languages"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Markup.Select"/>
                <CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Markup.Html"/>
            </CommandUIDefinitions>
        </CommandUIExtension>
    </CustomAction>
</Elements>


that’s works with the mayor browser:


If you want modify/hide/customize your ribbon I suggest to refer to msdn: http://msdn.microsoft.com/en-us/library/ee537543.aspx

bye

1 comment: