Back to Devexpress

DashboardViewer.CustomParameters Event

dashboard-devexpress-dot-dashboardwin-dot-dashboardviewer-6a2ec5e7.md

latest6.4 KB
Original Source

DashboardViewer.CustomParameters Event

Occurs before data is loaded from the data store and allows you to customize dashboard parameters that are used for data processing.

Namespace : DevExpress.DashboardWin

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

NuGet Package : DevExpress.Win.Dashboard

Declaration

csharp
public event CustomParametersEventHandler CustomParameters
vb
Public Event CustomParameters As CustomParametersEventHandler

Event Data

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

PropertyDescription
ParametersGets or sets dashboard parameters.

Remarks

The CustomParameters event provides access to a collection of dashboard parameters (CustomParametersEventArgs.Parameters) and allows you to change actual parameter values, parameter settings or even add new parameters. Note that parameter values specified in the CustomParameters event handler are used only for data processing and are not displayed in the Dashboard Parameters dialog.

For information on how to use the DashboardViewer.DashboardLoaded event to specify default parameter values, see the following example:

View Example: How to Specify Default Parameter Values in the WinForms Viewer

Example

The following example shows how to filter a custom SQL query by changing a parameter value in the DashboardViewer.CustomParameters event handler.

In this example, the custIDQueryParameter query parameter is included in a WHERE clause of a custom SQL query. The custIDQueryParameter parameter is also bound to the hidden custIDDashboardParameter dashboard parameter. The value of this parameter is changed at runtime by handling the DashboardViewer.CustomParameters event which is raised before the DashboardViewer sends a query to a database.

View Example

csharp
using DevExpress.DashboardCommon;
using System.Linq;

namespace Dashboard_CustomParameters_Win {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {
            InitializeComponent();
            dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");
        }

        private void dashboardViewer1_CustomParameters(object sender, CustomParametersEventArgs e) {
            var custIDParameter = e.Parameters.FirstOrDefault(p => p.Name == "custIDDashboardParameter");
            if (custIDParameter != null) {
                custIDParameter.Value = "AROUT";
            }
        }
    }
}
vb
Imports DevExpress.DashboardCommon
Imports System.Linq

Namespace Dashboard_CustomParameters_Win
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            InitializeComponent()
            dashboardViewer1.LoadDashboard("..\..\Data\Dashboard.xml")
        End Sub

        Private Sub dashboardViewer1_CustomParameters(ByVal sender As Object, ByVal e As CustomParametersEventArgs) Handles dashboardViewer1.CustomParameters
            Dim custIDParameter = e.Parameters.FirstOrDefault(Function(p) p.Name = "custIDDashboardParameter")
            If custIDParameter IsNot Nothing Then
                custIDParameter.Value = "AROUT"
            End If
        End Sub
    End Class
End Namespace

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomParameters event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-how-to-manage-dashboard-parameters-in-code/CS/CustomParametersExample/ViewerForm1.cs#L10

csharp
InitializeComponent();
dashboardViewer.CustomParameters += DashboardViewer_CustomParameters;
dashboardViewer.DashboardSource = typeof(SampleDashboard);

winforms-dashboard-how-to-manage-dashboard-parameters-in-code/VB/CustomParametersExample/ViewerForm1.vb#L13

vb
InitializeComponent()
AddHandler dashboardViewer.CustomParameters, AddressOf DashboardViewer_CustomParameters
dashboardViewer.DashboardSource = GetType(SampleDashboard)

Implements

CustomParameters

See Also

DashboardViewer Class

DashboardViewer Members

DevExpress.DashboardWin Namespace