Version

Adding Custom Tab to Ribbon Customization Dialog

By default, the Ribbon Customization dialog displays two tabs – Customize Ribbon and Quick Access Toolbar (QAT). (For details, refer to the Using the Ribbon Customization Dialog topic) You can, however, add custom tabs in addition to these default tabs. This topic shows through code how a custom tab can be implemented

Introduction

The WinRibbonCustomizationProvider™ component exposes two events, namely BeforeCustomizationDialogDisplayed and AfterCustomizationDialogClosed, with custom event arguments that expose the ribbon customization dialog in order to modify the dialog. The UltraTabControl is exposed on the dialog, which provides the ability to add custom tabs.

The code below illustrates adding a custom tab to the dialog. It is assumed that the form contains an UltraToolbarsManager set up with the ribbon and tools and an UltraRibbonCustomizationProvider component. The UltraRibbonCustomizationProvider component must be hooked up to the UltraToolbarsManager component in order to customize the Ribbon at run-time. For more information please see the Using the Ribbon Customization Dialog topic, Implementation section.

Note
Note

For the code to work properly, references to the following assemblies are required:

  • Infragistics4.Win.UltraWinToolbarsManager

  • Infragistics4.Win.UltraWinTabControl

  • Infragistics4.Win.UltraWinSchedule.

BeforeCustomizationDialogDisplayed Event

In Visual Basic:

Imports Infragistics.Win.UltraWinToolbars
' Add handler for the BeforeCustomizationDialogDisplayed Event.
Me.ultraRibbonCustomizationProvider1.BeforeCustomizationDialogDisplayed += New Infragistics.Win.SupportDialogs.RibbonCustomizationProvider.BeforeCustomizationDialogDisplayedEventHandler (ultraRibbonCustomizationProvider1_BeforeCustomizationDialogDisplayed)
Private Sub ultraRibbonCustomizationProvider1_BeforeCustomizationDialogDisplayed(sender As Object, e As Infragistics.Win.SupportDialogs.RibbonCustomizationProvider.BeforeCustomizationDialogDisplayedEventArgs)
    CreateCustomTabs(e.Dialog.TabControl)
End Sub

In C#:

using Infragistics.Win.UltraWinToolbars;
// Add handler for the BeforeCustomizationDialogDisplayed Event.
this.ultraRibbonCustomizationProvider1.BeforeCustomizationDialogDisplayed +=new
    Infragistics.Win.SupportDialogs.RibbonCustomizationProvider.BeforeCustomizationDialogDisplayedEventHandler
    (ultraRibbonCustomizationProvider1_BeforeCustomizationDialogDisplayed);
private void ultraRibbonCustomizationProvider1_BeforeCustomizationDialogDisplayed(object sender,
    Infragistics.Win.SupportDialogs.RibbonCustomizationProvider.BeforeCustomizationDialogDisplayedEventArgs e)
{
      CreateCustomTabs(e.Dialog.TabControl);
}

Creating a Custom Tab

In Visual Basic:

Imports Infragistics.Win.UltraWinToolbars
Imports Infragistics.Win.UltraWinTabControl
Imports Infragistics.Win.UltraWinSchedule
Private Sub CreateCustomTabs(tabControl1 As UltraTabControl)
    ' Add a custom tab to the tab control in the dialog
    Dim custTab As UltraTab = tabControl1.Tabs.Add("customTab1", "Custom Tab 1")
    tabControl1.ViewStyle = Infragistics.Win.UltraWinTabControl.ViewStyle.Office2007
    Dim ultraMonthView1 As New UltraMonthViewSingle()
    ultraMonthView1.Size = New Size(500, 300)
    ultraMonthView1.Location = New Point(90, 150)
    ultraMonthView1.Dock = DockStyle.Fill
    ' Add MonthViewSingle control to the custom tab.
    custTab.TabPage.Controls.Add(ultraMonthView1)
End Sub

In C#:

using Infragistics.Win.UltraWinToolbars;
using Infragistics.Win.UltraWinTabControl;
using Infragistics.Win.UltraWinSchedule;
private void CreateCustomTabs(UltraTabControl tabControl1)
        {
            // Add a custom tab to the tab control in the dialog
            UltraTab custTab = tabControl1.Tabs.Add("customTab1", "Custom Tab 1");
            tabControl1.ViewStyle = Infragistics.Win.UltraWinTabControl.ViewStyle.Office2007;
                UltraMonthViewSingle ultraMonthView1 = new UltraMonthViewSingle();
                ultraMonthView1.Size = new Size(500, 300);
                ultraMonthView1.Location = new Point(90,150);
                ultraMonthView1.Dock = DockStyle.Fill;
               // Add MonthViewSingle control to the custom tab.
                custTab.TabPage.Controls.Add(ultraMonthView1);
        }