我有一个简单的 c# winform,它使用报告查看器来显示报告。. 我的表格如下`
private void member_Search_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
if (key1 == "index")
{
try
{
this.report_membersTableAdapter.Fill(this.DataSet2.report_members, key1, "", value1, DateTime.Now, DateTime.Now);
this.reportViewer1.RefreshReport();
}
catch (Exception ex) {
MessageBox.Show("mbr_srh::ind" + ex.Message);
}
}
if (key1 == "name")
{
try
{
this.report_membersTableAdapter.Fill(this.DataSet2.report_members, key1, value1, "", DateTime.Now, DateTime.Now);
this.reportViewer1.RefreshReport();
}
catch (Exception ex) {
MessageBox.Show("mbr_srh::nam"+ex.Message);
}
}
if (key1 == "library")
{
try
{
this.report_membersTableAdapter.Fill(this.DataSet2.report_members, key1, "", "", d11, d22);
this.reportViewer1.RefreshReport();
}
catch (Exception ex) {
MessageBox.Show("mbr_srh::lib" + ex.Message);
}
}
if (key1 == "school")
{
try
{
this.report_membersTableAdapter.Fill(this.DataSet2.report_members, key1, "", "", d11, d22);
this.reportViewer1.RefreshReport();
}
catch (Exception ex) {
MessageBox.Show("mbr_srh::sch" + ex.Message);
}
}
}
public void set(string key, string value)
{
key1 = key;
value1 = value;
this.Show();
}
public void Setdate(string key, DateTime d1, DateTime d2)
{
key1 = key;
d11 = d1;
d22 = d2;
this.Show();
}
private void reportViewer1_Load(object sender, EventArgs e)
{
}
}
}`
我可以第一次调用set()
orsetdate()
函数,但是当我第二次调用上述函数时,它给了我一个例外cannot access a disposed object exception:object name:member_search
,突出显示this.Show()
orset()
函数setdate()
,有人可以帮我解决这个问题吗?