Back to Devexpress

Ribbon Page

windowsforms-2494-controls-and-libraries-ribbon-bars-and-menu-ribbon-visual-elements-ribbon-page.md

latest5.0 KB
Original Source

Ribbon Page

  • Apr 26, 2024
  • 3 minutes to read

Ribbon pages (RibbonPage) are displayed as tabs within the Ribbon UI. Ribbon pages incorporate Ribbon Groups that display commands, static items, editors, and galleries.

Create and Access Ribbon Pages

Watch the following tutorial video for general information on how to create and customize the Ribbon UI at design time:

Embedded content

Like other RibbonControl UI elements, you can easily access page settings at design time. Click the Ribbon page to select the page. Use the “Properties” window to customize page appearance, text, image, and visibility settings:

Standard Ribbon pages are stored in the RibbonControl.Pages collection. To create a standard Ribbon page in code, add a new RibbonPage object to the RibbonControl.Pages collection:

csharp
using DevExpress.XtraBars.Ribbon;

void AddNewRibbonPage(RibbonControl rc){
    RibbonPage page = new RibbonPage("My Ribbon Page");
    page.Groups.Add(new RibbonPageGroup("My Page Group"));
    rc.Pages.Add(page);
}
vb
Imports DevExpress.XtraBars.Ribbon

Private Sub AddNewRibbonPage(ByVal rc As RibbonControl)
    Dim page As New RibbonPage("My Ribbon Page")
    page.Groups.Add(New RibbonPageGroup("My Page Group"))
    rc.Pages.Add(page)
End Sub

Example: How to Obtain All Ribbon Pages in Code

Contextual Ribbon Pages and Categories

The WinForms Ribbon Control can display contextual pages with context-specific commands. Since these pages display context-specific commands, they don’t need to always be visible (only when a specific object is selected or when an end user performs a specific action).

The following image shows the Ribbon Control with three standard (Home, Alternative Page, and Gallery Page) and two contextual (Format and Clipboard) pages. The “Format” and “Clipboard” Ribbon pages belong to the “Selection” category:

Run Demo

Each Ribbon page belongs to a page category. Standard pages belong to the default page category. Contextual pages belong to custom page categories.

Read the following topics for additional information and code samples:

Add Page Groups

To add a Ribbon Page Group at design time, do one of the following:

  • Click the “Add Page Group” button (see the animation below).
  • Select the Ribbon page. Invoke its Smart Tag menu and select “Add Page Group”.

Use the Ribbon page’s Groups property to maintain (add/remove) its collection of Ribbon pages.

Select a Ribbon Page in Code

The RibbonControl.SelectedPage property specifies the selected/active Ribbon page. The following example selects the “Home” page:

csharp
ribbonControl1.SelectedPage = ribbonControl1.Pages["Home"];
vb
ribbonControl1.SelectedPage = ribbonControl1.Pages("Home")

The Ribbon Control fires the SelectedPageChanging event before selecting a page and allows you to cancel the action.

Show/Hide Ribbon Pages

Set theRibbon page’s Visible property to false to hide the page. To hide all pages that belong to a custom category, set the category’s Visible property to false.

See Also

Categories and Contextual Tabs