Skip to main content
All docs
V25.1
  • DashboardDesigner.DashboardStateChanged Event

    Occurs after the current dashboard state in the DashboardDesigner is changed.

    Namespace: DevExpress.DashboardWin

    Assembly: DevExpress.Dashboard.v25.1.Win.dll

    NuGet Package: DevExpress.Win.Dashboard

    Declaration

    public event DashboardStateChangedEventHandler DashboardStateChanged

    Event Data

    The DashboardStateChanged event's data class is DashboardStateChangedEventArgs. The following properties provide information specific to this event:

    Property Description
    DashboardState Gets the current state of the dashboard.

    Remarks

    A dashboard state contains the selected master filter values, current drill-down levels, Range Filter and Date Filter settings, dashboard item layers and current parameter values. Use the DashboardStateChanged event to get the actual dashboard state - the latest interaction changes a user made to a dashboard. The DashboardState property provides access to the states of individual dashboard items.

    You can use the DashboardDesigner.SetInitialDashboardState event to apply the state when a dashboard is loaded.

    For more information about a dashboard state, see Manage Dashboard State.

    Example

    The following code snippet demonstrates how to save a dashboard state each time it is changed.

    The DashboardDesigner.GetDashboardState method obtains a dashboard’s state object in the DashboardStateChanged event that is handled each time the dashboard state is changed. The state is serialized to XML and added to the XElement object stored in the CustomProperties collection.

    The dashboard state is restored in the DashboardDesigner.SetInitialDashboardState event handler.

    using DevExpress.DashboardCommon;
    using DevExpress.DashboardWin;
    // ...
    DashboardState state = new DashboardState();
    const string path = @"..\..\Dashboards\dashboard1.xml";
    // ... 
    private void DashboardDesigner_DashboardStateChanged(object sender, DashboardStateChangedEventArgs e) {
      state = dashboardDesigner.GetDashboardState();
      var stateValue = state.SaveToXml().ToString(SaveOptions.DisableFormatting);
      dashboardDesigner.Dashboard.CustomProperties.SetValue("DashboardState", stateValue);          
    }
    
    private void DashboardDesigner_SetInitialDashboardState(object sender, SetInitialDashboardStateEventArgs e) {
      e.InitialState = state;
    }
    // ...  
    
    See Also