Customizing the Windows Forms Ribbon
TX Text Control .NET for Windows Forms is shipped with a fully-featured, customizable and programmable Ribbon Bar with pre-configured Ribbon Tabs.

TX Text Control .NET for Windows Forms is shipped with a fully-featured, customizable and programmable Ribbon Bar with pre-configured Ribbon Tabs for the most typical applications of TX Text Control.
Changing the Ribbon Item's Text
In order to change the text of a RibbonItem (TXText
RibbonSplitButton ribbonItem = (RibbonSplitButton)ribbonFormattingTab1.FindItem(
RibbonFormattingTab.RibbonItem.TXITEM_Paste);
ribbonItem.Text = "New Text";
Adding Events to Ribbon Items
It is possible to attach additional events to existing ribbon buttons. The following code adds a click event to the Paste button:
RibbonSplitButton ribbonItem = (RibbonSplitButton)ribbonFormattingTab1.FindItem(
RibbonFormattingTab.RibbonItem.TXITEM_Paste);
ribbonItem.ButtonClick += RibbonItem_ButtonClick;
Removing Ribbon Items
The following code removes a ribbon button from the parent container, a TXText
RibbonSplitButton ribbonItem = (RibbonSplitButton)ribbonFormattingTab1.FindItem(
RibbonFormattingTab.RibbonItem.TXITEM_Paste);
if(ribbonItem.ParentCollection != null)
ribbonItem.ParentCollection.Remove(ribbonItem);
Removing Ribbon Groups
The next code snipped removes a complete ribbon groug; in this case, the Font ribbon group:
foreach (RibbonGroup group in ribbonFormattingTab1.RibbonGroups)
{
if (group.Name == "TXITEM_FontGroup")
{
ribbonFormattingTab1.RibbonGroups.Remove(group);
break;
}
}
Removing Ribbon Tabs
Complete ribbon tabs can be removed using the Controls property of the Windows.Forms.Ribbon.Ribbon control:
ribbon1.Controls.Remove(ribbonInsertTab1);
Creating New Ribbon Tabs
The following code creates a complete new Windows.Forms.Ribbon.RibbonTab with a new Windows.Forms.Ribbon.RibbonGroup. Additionally, a new Windows.Forms.Ribbon.RibbonButton is created and added to the created ribbon group. Finally, the ribbon tab is added to the Controls collection of the ribbon control and the selected tab is specified using the SelectedIndex property:
// create a new RibbonTab control and set the text (tab title)
RibbonTab myRibbonTab = new RibbonTab();
myRibbonTab.Text = "MyRibbonTab";
// create a new RibbonGroup
RibbonGroup myRibbonGroup = new RibbonGroup() { Text = "My Group" };
// make the dialog launcher icon invisible
myRibbonGroup.DialogBoxLauncher.Visible = false;
// add the new RibbonGroup to the RibbonGroup collection
// of the newly created RibbonTab
myRibbonTab.RibbonGroups.Add(myRibbonGroup);
// create a new RibbonButton
RibbonButton rbtnClickMe = new RibbonButton()
{
Text = "Click me!",
IsAddToQuickAccessToolbarEnabled = true,
};
// set some properties of the button and attach a "Click" event
rbtnClickMe.ToolTip.Title = "Tooltip Title";
rbtnClickMe.ToolTip.Description = "Tooltip Description";
rbtnClickMe.DisplayMode = IconTextRelation.LargeIconLabeled;
rbtnClickMe.LargeIcon = Image.FromFile("previewclose.png");
rbtnClickMe.Click += RbtnClickMe_Click;
rbtnClickMe.BackColor = Color.LawnGreen;
// add the button to the RibbonGroup
myRibbonGroup.RibbonItems.Add(rbtnClickMe);
// add the newly created RibbonTab to the Ribbon control
ribbon1.Controls.Add(myRibbonTab);
// set the selected tab to the new RibbonTab
ribbon1.SelectedIndex = ribbon1.TabCount - 1;
Happy coding!
Also See
This post references the following in the documentation:
- TXText
Control. Windows. Forms. Ribbon. Ribbon Button. Text Property - TXText
Control. Windows. Forms. Ribbon. Ribbon Formatting Tab. Find Item Method - TXText
Control. Windows. Forms. Ribbon. Ribbon Group Class - TXText
Control. Windows. Forms. Ribbon. Ribbon Group. Ribbon Items Property
Windows Forms
Text Control combines the power of a reporting tool and an easy-to-use WYSIWYG word processor - fully programmable and embeddable in your Windows Forms application. TX Text Control .NET for Windows Forms is a royalty-free, fully programmable rich edit control that offers developers a broad range of word processing features in a reusable component for Visual Studio.
Related Posts
Getting Started: Creating a .NET 8 Windows Forms Ribbon Application with…
This article shows how to create a Windows Forms application with a Ribbon and a Sidebar using TX Text Control .NET for Windows Forms. The Sidebar is a control that can be used to create a…
Windows Forms Ribbon: Displaying User-Friendly Merge Field Names
Database column names can be complex and confusing to end-users. This article shows how to display user-friendly names in the ribbon.
Using the Reporting RibbonTab
The Reporting RibbonTab provides all features to create out-of-the-box reporting applications.
Version X14: Customizing the Text Control Ribbon Control
TX Text Control X14 (24.0) comes with a fully-customizable, programmable Ribbon control. Pre-configured RibbonTabs can be used to create typical TX Text Control applications without writing a…
Adding Elements to the Ribbon QuickAccessToolbar
Version X14 implements a new Ribbon Control with the typical ribbon functionality and it comes with pre-configured ribbon tabs for the most typical tasks of TX Text Control. The Quick Access…