将datagridview的数据源设置为数据表时,窗口不响应 [英] Window not responding when setting datagridview's datasource as a datatable

查看:94
本文介绍了将datagridview的数据源设置为数据表时,窗口不响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我的应用程序处理大量记录.我使用datatable从sql服务器中获取数据.将Datagridview的datasource属性设置为如下所示的数据表

Hello Everyone
My application works with a large number of records.I used datatable to fetch data from the sql server. When setting the datasource property of the Datagridview as the datatable like below

DataGridView1.DataSource=myDataTable


在datagridview充满记录之前,Window才响应.我正在与至少5000行一起工作.有没有办法解决这个问题而没有屏幕挂起的问题.


谢谢大家


The Window is not responding till the datagridview filled with the records. I''m working with alteast of 5000 rows. Is there any way to do that without the screen hanging problem.


Thank You All

推荐答案

在不减少绑定到的记录数量的情况下,没有.由于您根本无法从后台线程以任何方式触摸控件,因此您别无选择,只能将操作放在UI线程上,就像已经做的那样.

我认为答案很明显.为什么当他们不想遍历每条记录时,为什么要在用户面前放置5,000条记录呢?
Without reducing the number of records you''re binding to, no. Since you can''t touch a control in any way at all from a background thread, you have no choice but to put this operation on the UI thread, as you are already doing.

I think the answer is pretty obvious. Why are you putting 5,000 records in front of the user when they''re not going to be looking through every single one of them?


这篇关于将datagridview的数据源设置为数据表时,窗口不响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆