dashboard-devexpress-dot-dashboardwin-dot-dashboardviewer-e93e2ba1.md
Reloads data in the data sources.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public void ReloadData()
Public Sub ReloadData
The following example demonstrates how to bind a dashboard to a List object.
The quantity values are provided at runtime. The dashboard data source is added to the Dashboard.DataSources collection on the first load.
Click the Reload Data button to call the DashboardViewer.ReloadData method. It raises the DashboardViewer.DataLoading event and supplies the dashboard with updated data.
View Example: How to Bind a Dashboard to a List of Objects
using System;
using System.Collections.Generic;
using System.Threading;
namespace Dashboard_BindingToList {
public class Data {
public string SalesPerson { get; set; }
public int Quantity { get; set; }
public static List<Data> CreateData() {
List<Data> data = new List<Data>();
string[] salesPersons = { "Andrew Fuller", "Michael Suyama", "Robert King", "Nancy Davolio",
"Margaret Peacock", "Laura Callahan", "Steven Buchanan", "Janet Leverling" };
for (int i = 0; i < 100; i++) {
Data record = new Data();
int seed = (int)DateTime.Now.Ticks & 0x0000FFFF;
record.SalesPerson = salesPersons[new Random(seed).Next(0, salesPersons.Length)];
record.Quantity = new Random(seed).Next(0, 100);
data.Add(record);
Thread.Sleep(3);
}
return data;
}
}
}
using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
using DevExpress.DataAccess;
using DevExpress.XtraEditors;
using System;
namespace Dashboard_BindingToList {
public partial class Form1 : XtraForm {
public Form1() {
InitializeComponent();
dashboardViewer1.DataSourceOptions.ObjectDataSourceLoadingBehavior = DocumentLoadingBehavior.LoadAsIs;
dashboardViewer1.CustomizeDashboardTitle += DashboardViewer1_CustomizeDashboardTitle;
}
private void Form1_Load(object sender, System.EventArgs e) {
Dashboard dashboard = new Dashboard();
DashboardObjectDataSource dataSource = new DashboardObjectDataSource("Data Source 1");
dashboardViewer1.DataLoading += (s, ev) => {
if (ev.DataSourceName == "Data Source 1")
ev.Data = Data.CreateData();
};
dashboard.DataSources.Add(dataSource);
PieDashboardItem pies = new PieDashboardItem();
pies.DataSource = dashboard.DataSources[0];
Dimension salesPersonArgument = new Dimension("SalesPerson");
Measure quantity = new Measure("Quantity");
pies.Arguments.Add(salesPersonArgument);
salesPersonArgument.TopNOptions.Enabled = true; salesPersonArgument.TopNOptions.Count = 3;
salesPersonArgument.TopNOptions.Measure = quantity;
pies.Values.Add(quantity);
GridDashboardItem grid = new GridDashboardItem();
grid.DataSource = dashboard.DataSources[0];
grid.Columns.Add(new GridDimensionColumn(new Dimension("SalesPerson")));
grid.Columns.Add(new GridMeasureColumn(new Measure("Quantity")));
dashboard.Items.AddRange(pies, grid);
dashboardViewer1.Dashboard = dashboard;
}
private void DashboardViewer1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e)
{
DashboardToolbarItem titleButton = new DashboardToolbarItem("Load Data",
new Action<DashboardToolbarItemClickEventArgs>((args) =>
{
dashboardViewer1.ReloadData();
}));
titleButton.Caption = "Reload Data";
e.Items.Add(titleButton);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Threading
Namespace Dashboard_BindingToList
Public Class Data
Public Property SalesPerson() As String
Public Property Quantity() As Integer
Public Shared Function CreateData() As List(Of Data)
'INSTANT VB NOTE: The variable data was renamed since it may cause conflicts with calls to static members of the user-defined type with this name:
Dim data_Renamed As New List(Of Data)()
Dim salesPersons() As String = { "Andrew Fuller", "Michael Suyama", "Robert King", "Nancy Davolio", "Margaret Peacock", "Laura Callahan", "Steven Buchanan", "Janet Leverling" }
For i As Integer = 0 To 99
Dim record As New Data()
Dim seed As Integer = CInt(Date.Now.Ticks And &HFFFF)
record.SalesPerson = salesPersons((New Random(seed)).Next(0, salesPersons.Length))
record.Quantity = (New Random(seed)).Next(0, 100)
data_Renamed.Add(record)
Thread.Sleep(3)
Next i
Return data_Renamed
End Function
End Class
End Namespace
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWin
Imports DevExpress.DataAccess
Imports DevExpress.XtraEditors
Imports System
Namespace Dashboard_BindingToList
Partial Public Class Form1
Inherits XtraForm
Public Sub New()
InitializeComponent()
dashboardViewer1.DataSourceOptions.ObjectDataSourceLoadingBehavior = DocumentLoadingBehavior.LoadAsIs
AddHandler dashboardViewer1.CustomizeDashboardTitle, AddressOf DashboardViewer1_CustomizeDashboardTitle
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dashboard As New Dashboard()
Dim dataSource As New DashboardObjectDataSource("Data Source 1")
AddHandler dashboardViewer1.DataLoading, Sub(s, ev)
If ev.DataSourceName = "Data Source 1" Then
ev.Data = Data.CreateData()
End If
End Sub
dashboard.DataSources.Add(dataSource)
Dim pies As New PieDashboardItem()
pies.DataSource = dashboard.DataSources(0)
Dim salesPersonArgument As New Dimension("SalesPerson")
Dim quantity As New Measure("Quantity")
pies.Arguments.Add(salesPersonArgument)
salesPersonArgument.TopNOptions.Enabled = True
salesPersonArgument.TopNOptions.Count = 3
salesPersonArgument.TopNOptions.Measure = quantity
pies.Values.Add(quantity)
Dim grid As New GridDashboardItem()
grid.DataSource = dashboard.DataSources(0)
grid.Columns.Add(New GridDimensionColumn(New Dimension("SalesPerson")))
grid.Columns.Add(New GridMeasureColumn(New Measure("Quantity")))
dashboard.Items.AddRange(pies, grid)
dashboardViewer1.Dashboard = dashboard
End Sub
Private Sub DashboardViewer1_CustomizeDashboardTitle(ByVal sender As Object, ByVal e As CustomizeDashboardTitleEventArgs)
Dim titleButton As DashboardToolbarItem = New DashboardToolbarItem("Load Data", New Action(Of DashboardToolbarItemClickEventArgs)(Sub(args)
dashboardViewer1.ReloadData()
End Sub))
titleButton.Caption = "Reload Data"
e.Items.Add(titleButton)
End Sub
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the ReloadData() method.
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-extract-data-source/CS/ExtractDataSourceExample/Form1.cs#L37
private void UpdateExtract() {
dashboardViewer1.ReloadData();
foreach (var ds in dashboardViewer1.Dashboard.DataSources.Where(d => d is DashboardExtractDataSource)) {
dashboardViewer.Dashboard.DataSources[0].Filter = "[State] In (?parameterState)";
dashboardViewer.ReloadData();
}
{
dashboardViewer1.ReloadData();
}));
winforms-dashboard-bind-pie-item-to-data-in-code/CS/Dashboard_CreatePies/Form1.cs#L39
dashboardViewer1.Dashboard = dashBoard;
dashboardViewer1.ReloadData();
}
winforms-dashboard-bind-pivot-item-to-data-in-code/CS/Dashboard_CreatePivot/Form1.cs#L41
dashboardViewer1.Dashboard = dashboard;
dashboardViewer1.ReloadData();
}
winforms-dashboard-extract-data-source/VB/ExtractDataSourceExample/Form1.vb#L42
Private Sub UpdateExtract()
dashboardViewer1.ReloadData()
For Each ds In dashboardViewer1.Dashboard.DataSources.Where(Function(d) TypeOf d Is DashboardExtractDataSource)
dashboardViewer.Dashboard.DataSources(0).Filter = "[State] In (?parameterState)"
dashboardViewer.ReloadData()
End Sub
Dim titleButton As DashboardToolbarItem = New DashboardToolbarItem("Load Data", New Action(Of DashboardToolbarItemClickEventArgs)(Sub(args)
dashboardViewer1.ReloadData()
End Sub))
winforms-dashboard-bind-pie-item-to-data-in-code/VB/Dashboard_CreatePies/Form1.vb#L37
dashboardViewer1.Dashboard = dashBoard
dashboardViewer1.ReloadData()
End Sub
winforms-dashboard-bind-pivot-item-to-data-in-code/VB/Dashboard_CreatePivot/Form1.vb#L33
dashboardViewer1.Dashboard = dashboard
dashboardViewer1.ReloadData()
End Sub
See Also