Back to Devexpress

Ribbon Message

windowsforms-404480-controls-and-libraries-ribbon-bars-and-menu-ribbon-visual-elements-ribbon-message.md

latest3.5 KB
Original Source

Ribbon Message

  • May 07, 2024
  • 2 minutes to read

The Ribbon control can display messages - Office-inspired flyout notifications and alerts. The Ribbon control stores its messages within the Messages collection.

Run Demo

Messages from child merged ribbons are stored in the MergedMessages collection.

Show Message

Use the ShowMessage method to display a Ribbon message. This method accepts a RibbonMessageArgs object, which contains information about the message (title, description, icon, buttons, and color).

Close Message

Use the CloseMessage(RibbonMessageArgs, DialogResult) method to close the specified Ribbon message.

The Ribbon control raises the MessageClosed event after a message is closed and allows you to handle button clicks.

Example

csharp
using DevExpress.XtraBars.Ribbon;

void ShowMessage() {
    RibbonMessageArgs args = new RibbonMessageArgs();
    args.Caption = "What's New";
    args.Text = "Explore our new WinForms-related features we expect to introduce in our first major update this year (v23.1).";
    args.Icon = MessageBoxIcon.Information;
    args.Buttons = new DialogResult[] { DialogResult.OK };
    args.Showing += Args_Showing;
    Ribbon.ShowMessage(args);
    Ribbon.MessageClosed += Ribbon_MessageClosed;
}
void Ribbon_MessageClosed(object sender, RibbonMessageClosedArgs e) {
    if(e.Result == DialogResult.OK)
        DevExpress.Data.Utils.SafeProcess.Start("https://community.devexpress.com/blogs/winforms/archive/2023/02/16/devexpress-winforms-roadmap-23-1.aspx");
}
void Args_Showing(object sender, RibbonMessageShowingArgs e) {
    e.Buttons[DialogResult.OK].Caption = "Explore Roadmap";
}
vb
Imports DevExpress.XtraBars.Ribbon

Private Sub ShowMessage()
    Dim args As New RibbonMessageArgs()
    args.Caption = "What's New"
    args.Text = "Explore our new WinForms-related features we expect to introduce in our first major update this year (v23.1)."
    args.Icon = MessageBoxIcon.Information
    args.Buttons = New DialogResult() { DialogResult.OK }
    AddHandler args.Showing, AddressOf Args_Showing
    Ribbon.ShowMessage(args)
    AddHandler Ribbon.MessageClosed, AddressOf Ribbon_MessageClosed
End Sub
Private Sub Ribbon_MessageClosed(ByVal sender As Object, ByVal e As RibbonMessageClosedArgs)
    If e.Result = DialogResult.OK Then
        DevExpress.Data.Utils.SafeProcess.Start("https://community.devexpress.com/blogs/winforms/archive/2023/02/16/devexpress-winforms-roadmap-23-1.aspx")
    End If
End Sub
Private Sub Args_Showing(ByVal sender As Object, ByVal e As RibbonMessageShowingArgs)
    e.Buttons(DialogResult.OK).Caption = "Explore Roadmap"
End Sub

The following image shows the result: