使用BindingSource对象将DataTable绑定到DataGridView [英] Binding a DataTable to a DataGridView using a BindingSource Object

查看:176
本文介绍了使用BindingSource对象将DataTable绑定到DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个使用bindingsource对象绑定到datagridview的数据表.我有一台外部服务器,它向我的程序发送更新.当程序收到更新时,它将向包含新信息的数据表添加新行.由于数据表已绑定到datagridview,因此它也会更新,以便用户可以看到新信息.我的问题是,新数据更新是通过单独的线程传递给程序的,因此datagridview是由创建线程的线程以外的线程间接更新的.由于绑定源在更新数据表时会自动更新datagridview,因此我无法确定应在何处调用datagridview.我查看了bindingsource.ListChanged事件,但不确定在将更改传输到datagridview之前是否引发此事件.

任何帮助将不胜感激

在此先感谢

J

Hi
I have a datatable bound to a datagridview, using a bindingsource object. I have an external server that sends updates to my program. When the program receives the updates, it adds a new row to the datatable containing the new information. As the datatable is bound to the datagridview, it also updates so the user can see the new information. My problem is that, the new data updates are passed to the programme on a seperate thread and so the datagridview is indirectly being updated by a thread other than the one it was created on. As the bindingsource automatically updates the datagridview when the datatable is updated, i cant figure out where i should invoke the datagridview. I looked at the bindingsource.ListChanged Event, but was not sure whether this is raised before the changed has been transmitted through to the datagridview.

Any Help would be much appreciated

Thanks very much in advance

J

推荐答案

您的方案就像聊天应用程序.
消息会在其中更新列表.
尝试搜索聊天应用程序,您可能会想更新GridView.
Your scenario is like chat application.
In which list is updated by the message.
Try search chat application , u may have idea to update your GridView.


这篇关于使用BindingSource对象将DataTable绑定到DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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