The requested page is not available for the requested platform. You are viewing the content for Default platform.

DashboardDesigner.DashboardOpening Event

Allows you to implement custom logic for dashboard opening.

Namespace: DevExpress.DashboardWin

Assembly: DevExpress.Dashboard.v18.2.Win.dll

Declaration

public event DashboardOpeningEventHandler DashboardOpening
Public Event DashboardOpening As DashboardOpeningEventHandler

Event Data

The DashboardOpening event handler receives an argument of the DashboardOpeningEventArgs type. The following properties provide information specific to this event.

Property Description
Dashboard Gets or sets the dashboard that will be opened.
Handled Gets or sets whether the dashboard to be opened has been provided.

Remarks

The DashboardOpening event is raised when a when an end-user clicks the Open button. Handle this event to override the default Open File dialog and implement custom actions.

Assign the dashboard that should be opened to the event parameter's DashboardOpeningEventArgs.Dashboard property.

After you have provided the dashboard, set the DashboardOpeningEventArgs.Handled property to true. Otherwise, the default actions will be performed, i.e., the Open File dialog will be invoked and the dashboard selected by the end-user will be opened.

When an end-user creates or saves a dashboard, the DashboardDesigner raises the DashboardDesigner.DashboardCreating or DashboardDesigner.DashboardSaving event respectively.

Examples

The following example demonstrates how to implement custom saving and opening procedures in Dashboard Designer using the DashboardDesigner.DashboardSaving and DashboardDesigner.DashboardOpening events respectively.

In this example, the dashboard XML definition can be saved (opened) only to(from) the specified default location.

The DashboardDesigner.DashboardSaving event is handled to implement a custom saving routine. Its DashboardSavingEventArgs.Command event parameter allows determining what user action raises the event. The Dashboard.SaveToXml method is used to save the dashboard to the specified XML file. Then, the DashboardSavingEventArgs.Handled event parameter is used to specify that the dashboard has been saved and no default actions are required.

Clicking the Save As button invokes a message box that allows saving the dashboard to the default location or cancel the saving procedure. The DashboardSavingEventArgs.Saved event parameter is used to notify whether the custom saving routine has succeeded.

The DashboardDesigner.DashboardOpening event is handled to implement a custom opening procedure. The DashboardDesigner.LoadDashboard method is called to load the dashboard from the default location. The DashboardOpeningEventArgs.Handled event parameter allows specifying that no default actions are required to open the dashboard.

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

namespace Dashboard_LoadingAndSaving {
    public partial class Form1 : RibbonForm {

        // Specifies the path to the dashboard XML definition.
        string filePath = @"..\..\Data\DashboardDefinition.xml";

        public Form1() {
            InitializeComponent();

            // Creates and initializes a Ribbon in the DashboardDesigner's parent control.
            dashboardDesigner1.CreateRibbon();

            // Loads a dashboard from an XML file.
            dashboardDesigner1.LoadDashboard(filePath);
        }

        // Handles the DashboardSaving event.
        private void dashboardDesigner1_DashboardSaving(object sender, 
            DevExpress.DashboardWin.DashboardSavingEventArgs e) {

            // Determines whether the user has called the Save command.
            if (e.Command == DevExpress.DashboardWin.DashboardSaveCommand.Save) {

                // Saves the dashboard to the specified XML file.
                dashboardDesigner1.Dashboard.SaveToXml(filePath);

                // Specifies that the dashboard has been saved and no default actions are required.
                e.Handled = true;
            }

            // Determines whether the user has called the Save As command.
            if (e.Command == DevExpress.DashboardWin.DashboardSaveCommand.SaveAs) {
                DialogResult result = InvokeMessageBox();
                if (result == System.Windows.Forms.DialogResult.OK) {
                    dashboardDesigner1.Dashboard.SaveToXml(filePath);
                    e.Handled = true;

                    // Specifies that the dashboard has been saved.
                    e.Saved = true;
                }
                if (result == System.Windows.Forms.DialogResult.Cancel) {
                    e.Handled = true;
                    e.Saved = false;
                }
            }
        }

        // Handles the DashboardOpening event.
        private void dashboardDesigner1_DashboardOpening(object sender, 
            DevExpress.DashboardWin.DashboardOpeningEventArgs e) {

            // Loads the previously saved dashboard from an XML file.
            dashboardDesigner1.LoadDashboard(filePath);

            // Specifies that the dashboard opening procedure has been provided.
            e.Handled = true;
        }
    }
}
See Also