Skip to main content

RibbonForm Class

A form that integrates a RibbonControl.

Namespace: DevExpress.XtraBars.Ribbon

Assembly: DevExpress.XtraBars.v25.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public class RibbonForm :
    XtraForm,
    ISupportGlassRegions,
    IBarObjectContainer,
    ISupportFormShadow

Remarks

A RibbonForm derives from the XtraForm class with the integrated Ribbon UI.

WinForms Ribbon Form, DevExpress

Create a RibbonForm

using DevExpress.XtraBars.Ribbon;

namespace MyApp {
    public partial class MainForm : RibbonForm {
        public MainForm() {
            InitializeComponent();
            InitializeRibbon();
        }

        void InitializeRibbon() {
            // Set application and document captions.
            ribbonControl1.ApplicationCaption = "My Application";
            ribbonControl1.ApplicationDocumentCaption = "Home Page";
            // Create and customize the BackstageViewControl at design time.
            // Attach the BackstageViewControl to the RibbonControl.
            ribbonControl1.ApplicationButtonDropDownControl = backstageViewControl1;
        }
    }
}

Outlook-inspired Side Navigation

Use the following properties to replicate the side navigation layout of Microsoft Outlook for Windows:

  • NavigationControl - specifies the navigation control as a side navigation element (such as an AccordionControl, NavigationPane, or ToolboxControl).
  • NavigationControlLayoutMode - Aligns the side navigation relative to the form’s title.

The following code snippet creates a side navigation inspired by the new Microsoft Outlook:

using DevExpress.XtraBars.Navigation;
using DevExpress.XtraBars.Ribbon;
using System.Windows.Forms;

namespace DXApplication {
    public partial class Form1 : RibbonForm {
        AccordionControl accordion;
        public Form1() {
            InitializeComponent();
            accordion = new AccordionControl() { Dock = DockStyle.Left };
            this.Controls.Add(accordion);
            this.NavigationControl = accordion;
            this.NavigationControlLayoutMode = RibbonFormNavigationControlLayoutMode.StretchToFormTitle;
            CreateAccordionItems();
        }
        void CreateAccordionItems() {
            AccordionControlElement group1 = new AccordionControlElement(ElementStyle.Group) {
                Name = "group1",
                Text = "Contacts",
                Expanded = true
            };
            AccordionControlElement item1 = new AccordionControlElement(ElementStyle.Item) {
                Name = "itemCustomers",
                Text = "Customers",
            };
            AccordionControlElement item2 = new AccordionControlElement(ElementStyle.Item) {
                Name = "itemEmployees",
                Text = "Employees"
            };

            group1.Elements.AddRange(new AccordionControlElement[] { item1, item2 });
            accordion.Elements.Add(group1);
        }
    }
}

RibbonFormNavigationControlLayoutMode.StretchToTop

Dual Captions

The form header consists of two parts that allow you to specify the application name and the name of the active document:

Application Button

In Office 2007 style, the Application Button is displayed within the title bar. In other styles, the button is displayed below the title bar.

Show/Hide the Button

Use the ShowApplicationButton property to show or hide the Application button:

// Show the Application Button.
ribbonControl1.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.True;

// Hide the Application Button
ribbonControl1.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.False;

Assign a Drop-Down Control

Use the ApplicationButtonDropDownControl property to display a drop-down control when the user clicks the Application Button. You can attach a BackstageViewControl or a custom menu:

// Attach a BackstageViewControl created at design time.
ribbonControl1.ApplicationButtonDropDownControl = backstageViewControl1;

// Or attach a custom popup menu.
// ribbonControl.ApplicationButtonDropDownControl = myPopupMenu;

Handle Button Click

Use the ApplicationButtonClick event to run custom code when the user clicks the button:

ribbonControl1.ApplicationButtonClick += (sender, e) => {
    // Insert your logic here.
    MessageBox.Show("Application Button clicked");
};

Specific Notes

  • The RibbonForm does not support RightToLeftLayout and RightToLeft properties.
  • Do not set the RibbonForm’s FormBorderStyle property to None.
  • Do not add a BarManager to a RibbonForm.

Important

When a DockManager is placed on a RibbonForm, you may notice slow performance during control startup rendering for complex projects. To resolve the issue, call the DockManager.ForceInitialize method on form loading.

Inheritance

Show 14 items
See Also