我在 Form2 中有以下代码
public void authorisedList()
{
using (myContext v = new myContext())
{
DateTime date = DateTime.Today.AddMonths(-12);
var myList = (from l in v.AuthorisedList
where l.FromDate >= date
select new
{
l.ID,
l.EmpName,
l.StartDate,
l.EndDate,
l.Days,
l.Approved,
l.Confirmed,
}).ToList();
reportViewer1.LocalReport.DataSources.Clear();
ReportDataSource datasource = new ReportDataSource("MyReportsDatasource", myList);
reportViewer1.LocalReport.DataSources.Add(datasource);
string exeFolder = Path.GetDirectoryName(Application.ExecutablePath);
string reportPath = Path.Combine(exeFolder, @"rdlcReports\Authorised List.rdlc");
reportViewer1.LocalReport.ReportPath = reportPath;
reportViewer1.RefreshReport();
}
}
然后在Form2的父Form1中,我在单选按钮中有以下代码
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
Form2 au = new Form2(this);
au.authorisedList();
}
问题是,当我检查 Form1 中的 radioButton 控件(radioButton1)时,Form2 中的 authorisedList() 似乎正在执行,但 reportViewer 报告没有更新/更改。
我想知道为什么。