Public Partial Class Form1
Inherits Form
Public Event ReportRefresh As CancelEventHandler
Private reportDataSource As New ReportDataSource()
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs)
' TODO: This line of code loads data into the 'DataSet1.Supplier' table. You can move, or remove it, as needed.
Me.SupplierTableAdapter.Fill(Me.DataSet1.Supplier)
reportDataSource.Name = "DataSet1_Supplier"
reportDataSource.Value = Me.DataSet1.Supplier
Me.reportViewer1.LocalReport.DataSources.Clear()
Me.reportViewer1.ReportRefresh += New CancelEventHandler(AddressOf reportViewer1_ReportRefresh)
Me.reportViewer1.LocalReport.DataSources.Add(reportDataSource)
Me.reportViewer1.RefreshReport()
End Sub
Private Sub reportViewer1_ReportRefresh(sender As Object, e As CancelEventArgs)
Me.SupplierTableAdapter.Fill(Me.DataSet1.Supplier)
reportDataSource.Value = Me.DataSet1.Supplier
End Sub
End Class
Code (C#)
public partial class Form1 : Form
{
public event CancelEventHandler ReportRefresh;
ReportDataSource reportDataSource = new ReportDataSource();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'DataSet1.Supplier' table. You can move, or remove it, as needed.
this.SupplierTableAdapter.Fill(this.DataSet1.Supplier);
reportDataSource.Name = "DataSet1_Supplier";
reportDataSource.Value = this.DataSet1.Supplier;
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.ReportRefresh += new CancelEventHandler(reportViewer1_ReportRefresh);
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
this.reportViewer1.RefreshReport();
}
private void reportViewer1_ReportRefresh(object sender, CancelEventArgs e)
{
this.SupplierTableAdapter.Fill(this.DataSet1.Supplier);
reportDataSource.Value = this.DataSet1.Supplier;
}
}