关于datagridview在多线程中滚动条无法使用的有关问题
关于datagridview在多线程中滚动条无法使用的问题
private delegate void InvokeHandler();
//子线程中
this.Invoke(new InvokeHandler(delegate()
{
dataGridView1.DataSource = null;
dataGridView1.DataSource = dgv_dt;
}));
在网上查的到是这么解决的,但是我不知道该把代码贴在哪里,dgv_dt应该换成我自己的datatable值
我的代码是这样的
try
{
Thread th = new Thread(Allorder);
th.IsBackground = true;
th.Start();
dataGridViewOrderResult.Invoke(new InvokeHandler(delegate()
{
dataGridViewOrderResult.DataSource = null;
dataGridViewOrderResult.DataSource = this.dtMy;
}));
}//try
catch
{
MessageBox.Show("请导入任务单");
}
这样贴进去没用为什么没用,贴到Allorder方法里也没用
------解决思路----------------------
到低是滚动条无法使用,还是怎么了?
------解决思路----------------------
不知道是不是我懂得少你的InvokeHandler委托里添加的方法对吗?建议你分开单独使用试试吧,这个代码应该放到Allorder中的吧,而且你这里既没有循环也没有触发条件,委托应该只会执行一次吧,你再好好理理,单步跟一下,我觉得里面问题不少
private delegate void InvokeHandler();
//子线程中
this.Invoke(new InvokeHandler(delegate()
{
dataGridView1.DataSource = null;
dataGridView1.DataSource = dgv_dt;
}));
在网上查的到是这么解决的,但是我不知道该把代码贴在哪里,dgv_dt应该换成我自己的datatable值
我的代码是这样的
try
{
Thread th = new Thread(Allorder);
th.IsBackground = true;
th.Start();
dataGridViewOrderResult.Invoke(new InvokeHandler(delegate()
{
dataGridViewOrderResult.DataSource = null;
dataGridViewOrderResult.DataSource = this.dtMy;
}));
}//try
catch
{
MessageBox.Show("请导入任务单");
}
这样贴进去没用为什么没用,贴到Allorder方法里也没用
------解决思路----------------------
到低是滚动条无法使用,还是怎么了?
------解决思路----------------------
不知道是不是我懂得少你的InvokeHandler委托里添加的方法对吗?建议你分开单独使用试试吧,这个代码应该放到Allorder中的吧,而且你这里既没有循环也没有触发条件,委托应该只会执行一次吧,你再好好理理,单步跟一下,我觉得里面问题不少