dashboard-devexpress-dot-dashboardwin-dot-dashboarddesigner.md
Allows you to customize connection settings before the DashboardDesigner connects to a data store (database, OLAP cube, etc.).
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public event DashboardConfigureDataConnectionEventHandler ConfigureDataConnection
Public Event ConfigureDataConnection As DashboardConfigureDataConnectionEventHandler
The ConfigureDataConnection event's data class is DashboardConfigureDataConnectionEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| ConnectionName | Gets the name of the connection for which the event has been raised. Inherited from ConfigureDataConnectionEventArgs. |
| ConnectionParameters | Gets or sets parameters used to establish a connection to data. Inherited from ConfigureDataConnectionEventArgs. |
| DataSourceName | Gets the data source name for which the event was raised. |
The ConfigureDataConnection event occurs before connecting to a data source and allows you to customize connection settings.
This event is raised when the dashboard is supplied with data using one of the following data source types:
If the dashboard is bound to the DashboardObjectDataSource, the DashboardDesigner.DataLoading event fires instead.
To specify connection parameters, cast an object the e.ConnectionParameters property returns to the DataConnectionParametersBase descendant. The following table lists the different data sources and their corresponding descendants:
|
Data Source
|
Parameter Type
| | --- | --- | |
|
The SqlServerConnectionParametersBase class is the base type and defines the basic connection parameters: DatabaseName, Password, ServerName and UserName.
To specify other data provider parameters, cast an object to any of the types listed in the DevExpress.DataAccess.ConnectionParameters namespace. Here are some of the types:
You can also add a custom connection string. Cast an object to the CustomStringConnectionParameters class and assign a custom connection string to the ConnectionString property.
Tip
You can use a custom connection string to get data from an XML file that contains valid schema, for example, “xpoprovider=InMemoryDataStore;data source=””your_data_file.xml””;read only=True”
| |
|
Cast an object to the OlapConnectionParameters type and use the ConnectionString property.
| |
|
Cast an object to the ExcelDataSourceConnectionParameters type and use the FileName and Password properties.
| |
|
Cast an object to the ExtractDataSourceConnectionParameters type and use the FileName and DriverName properties.
| |
|
Event does not occur.
| |
|
Event does not occur.
Handle the DataLoading / AsyncDataLoading event instead:
| |
|
Cast an object to the JsonSourceConnectionParameters type and use the JsonSource property.
You can also add a custom connection string. Cast an object to the CustomStringConnectionParameters class and assign a custom connection string to the ConnectionString property.
| |
|
Cast an object to the MongoDBCustomConnectionParameters type and use the following connection parameters:
|
Tip
Refer to the following topic for information about custom connection strings: Custom Connection Strings for Data Sources
The following code snippet shows how to handle the ConfigureDataConnection event for various data source types:
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
// ...
dashboardDesigner.ConfigureDataConnection += dashboardDesigner_ConfigureDataConnection;
// ...
private void dashboardDesigner_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e){
if (e.DataSourceName == "sqliteDataSource"){
SQLiteConnectionParameters parameters = e.ConnectionParameters as SQLiteConnectionParameters;
if (parameters != null){
parameters.FileName = "file:Data\nwind.db";
parameters.Password = "test";
}
}
if (e.DataSourceName == "olapDataSource"){
OlapConnectionParameters parameters = e.ConnectionParameters as OlapConnectionParameters;
if (parameters != null){
parameters.ConnectionString = "Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;"
+ "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;";
}
}
if (e.DataSourceName == "extractDataSource"){
ExtractDataSourceConnectionParameters parameters = e.ConnectionParameters as ExtractDataSourceConnectionParameters;{
if (parameters != null){
parameters.FileName = "file:Data\nwind.dat";
}
}
}
if (e.DataSourceName == "oracleDataSource"){
OracleConnectionParameters parameters = e.ConnectionParameters as OracleConnectionParameters;
if (parameters != null){
parameters.ProviderType = OracleProviderType.ODPManaged;
parameters.ServerName = "dashboarddb:1521/OracleTest";
parameters.UserName = "user";
parameters.Password = "test";
}
}
if (e.DataSourceName == "excelDataSource"){
ExcelDataSourceConnectionParameters parameters = e.ConnectionParameters as ExcelDataSourceConnectionParameters;
if (parameters != null){
parameters.FileName = "file:Data\nwind.xlsx";
parameters.Password = "test";
}
}
}
Imports Microsoft.VisualBasic
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.ConnectionParameters
' ...
AddHandler dashboardDesigner.ConfigureDataConnection, AddressOf dashboardDesigner_ConfigureDataConnection
' ...
Private Sub dashboardDesigner_ConfigureDataConnection(ByVal sender As Object, ByVal e As DashboardConfigureDataConnectionEventArgs)
If e.DataSourceName = "sqliteDataSource" Then
Dim parameters As SQLiteConnectionParameters = TryCast(e.ConnectionParameters, SQLiteConnectionParameters)
If parameters IsNot Nothing Then
parameters.FileName = "file:Data" & Constants.vbLf & "wind.db"
parameters.Password = "test"
End If
End If
If e.DataSourceName = "olapDataSource" Then
Dim parameters As OlapConnectionParameters = TryCast(e.ConnectionParameters, OlapConnectionParameters)
If parameters IsNot Nothing Then
parameters.ConnectionString = "Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" & "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;"
End If
End If
If e.DataSourceName = "extractDataSource" Then
Dim parameters As ExtractDataSourceConnectionParameters = TryCast(e.ConnectionParameters, ExtractDataSourceConnectionParameters)
If parameters IsNot Nothing Then
parameters.FileName = "file:Data" & Constants.vbLf & "wind.dat"
End If
End If
If e.DataSourceName = "oracleDataSource" Then
Dim parameters As OracleConnectionParameters = TryCast(e.ConnectionParameters, OracleConnectionParameters)
If parameters IsNot Nothing Then
parameters.ProviderType = OracleProviderType.ODPManaged
parameters.ServerName = "dashboarddb:1521/OracleTest"
parameters.UserName = "user"
parameters.Password = "test"
End If
End If
If e.DataSourceName = "excelDataSource" Then
Dim parameters As ExcelDataSourceConnectionParameters = TryCast(e.ConnectionParameters, ExcelDataSourceConnectionParameters)
If parameters IsNot Nothing Then
parameters.FileName = "file:Data" & Constants.vbLf & "wind.xlsx"
parameters.Password = "test"
End If
End If
End Sub
This code snippet is the ConfigureDataConnection event handler that allows you to specify the extract data source’s file location before the dashboard loads.
View Example: How to set master filter in DashboardViewer
using DevExpress.DashboardCommon;
// ...
dashboardDesigner.ConfigureDataConnection += dashboardDesigner_ConfigureDataConnection;
// ...
private void dashboardDesigner_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e)
{
ExtractDataSourceConnectionParameters parameters = e.ConnectionParameters as ExtractDataSourceConnectionParameters;
if (parameters != null)
parameters.FileName = Path.GetFileName(parameters.FileName);
}
Imports DevExpress.DashboardCommon
' ...
AddHandler dashboardDesigner.ConfigureDataConnection, AddressOf dashboardDesigner_ConfigureDataConnection
' ...
Private Sub dashboardDesigner_ConfigureDataConnection(ByVal sender As Object, ByVal e As DashboardConfigureDataConnectionEventArgs)
Dim parameters As ExtractDataSourceConnectionParameters = TryCast(e.ConnectionParameters, ExtractDataSourceConnectionParameters)
If parameters IsNot Nothing Then
parameters.FileName = Path.GetFileName(parameters.FileName)
End If
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the ConfigureDataConnection 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-customize-exported-document/CS/CustomExportDocumentExample/Form1.cs#L15
dashboardDesigner1.CreateRibbon();
dashboardDesigner1.ConfigureDataConnection += DashboardDesigner1_ConfigureDataConnection;
dashboardDesigner1.LoadDashboard("Dashboard.xml");
dashboardDesigner1.CustomizeDashboardItemCaption += DashboardDesigner1_CustomizeDashboardItemCaption;
dashboardDesigner1.ConfigureDataConnection += DashboardDesigner1_ConfigureDataConnection;
dashboardDesigner1.CreateRibbon();
winforms-dashboard-customize-exported-document/VB/CustomExportDocumentExample/Form1.vb#L14
dashboardDesigner1.CreateRibbon()
AddHandler dashboardDesigner1.ConfigureDataConnection, AddressOf DashboardDesigner1_ConfigureDataConnection
dashboardDesigner1.LoadDashboard("Dashboard.xml")
AddHandler dashboardDesigner1.CustomizeDashboardItemCaption, AddressOf DashboardDesigner1_CustomizeDashboardItemCaption
AddHandler dashboardDesigner1.ConfigureDataConnection, AddressOf DashboardDesigner1_ConfigureDataConnection
dashboardDesigner1.CreateRibbon()
See Also