##winform程序的Application.Run()抛出异常:“未将对象引用设置到对象的实例“
###下面是调试时感觉出问题的地方:
//触发事件
private void MC_Code_SelectedIndexChanged(object sender, EventArgs e)
{
label8.Text = MC_Code.Text;
if (MC_Code.Text == null)
return;
mc_code = MC_Code.Text;
Dept_Code = dept_code.Text;
try
{
Thread thr = new Thread(loadDataGridView);
thr.Start();
}
catch
{
}
}
string mc_code = "";
string Dept_Code = "";
***#感觉出问题的函数#***
void loadDataGridView()
{
DataTable table = new DataTable();
//BindingSource bs = new BindingSource();
while (true)
{
table = getData(mc_code, Dept_Code, Login.Site);
if (table == null)
return;
//BindingSource bs = new BindingSource();
//bs.DataSource = table;
//bs.DataMember = "Data";
try
{
//第一次在下拉列表中选择一个值代码运行到此处,不会出现任何问题;但是当在下拉列表中重新选择值第二次运行到此处时,就会跳转到Application.Run()这个地方抛出异常:“未将对象引用设置到对象的实例“
#this.dataGridView1.DataSource = table;#
//this.dataGridView1.DataBindings.Add("Text",bs,"");
}
catch
{
return;
}
Thread.Sleep(60000);
}
}
**不知道具体是什么问题,求大神解决!**