为什么不datagridview的刷新? [英] why doesn't datagridview refresh?

查看:243
本文介绍了为什么不datagridview的刷新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里后,我碰巧preSS按钮是什么:

here is what happens after i press a button:

    dataGridView1.DataSource = ConnectandReadList(some_query);
    dataGridView1.Refresh();

请注意,我做这与所谓的另一个控制 Chart1的和它的作品与它的罚款,它填充它与新重新查询数据,但 datagridview的只是停留在同一个

please note that i am doing this with another control called chart1 and it works fine with it, it populates it with the new requeried data, but datagridview is just staying the same

的第一次尝试是成功的。

the first attempt is successful.

不过我第二次preSS,它显示了同样的事情!

however the second time i press it, it display the same thing!

谁知道我是否正确地刷新datagridview的?

anyone know whether i am refreshing the datagridview correctly?

推荐答案

一个DataGridView设置绑定你第一次分配的数据源。的问题是,随后的数据源的分配,如果分配有从初始分配一个不同的结构,将失败,因为绑定是现在被关掉

A DataGridView sets up bindings the first time you assign the DataSource. The problem is that subsequent DataSource assignments, if the assignments have a different structure from the initial assignment, will fail because the bindings are now "off"

您需要重置的DataGridView 正是如此的,这样的数据绑定一个新的。 (链接是VB的,但你只需要知道调用,即使复制/粘贴将是矫枉过正的方法。)

You need to reset the DataGridView thusly so that the data is bound a new. (The link is for VB but you just need to know the methods to call. Even copy/paste would be overkill.)

这篇关于为什么不datagridview的刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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