vb.net中的DevExpress刷新datagridview不起作用 [英] DevExpress Refreshing datagridview in vb.net not working

查看:78
本文介绍了vb.net中的DevExpress刷新datagridview不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DevExpress在vb.net中刷新datagridview不起作用.

DevExpress Refreshing datagridview in vb.net not working.

我从数据库中将一个表加载到datagridview并显示所有数据

I load one table from my database to datagridview and it display all the data

问题-当我将另一个表从数据库加载到datagridview时,它不起作用.仅第一个表将显示其数据,而第二个表将不向datagridview显示任何数据.

Problem - When I load another table from database to datagridview, It wasn't working. Only the first table will display its data while the second table won't display any data to datagridview.

推荐答案

这种行为有两个可能的原因:

There are two possible reasons for this kind of behavior:

  1. 第二个数据表中的列不同.

其症状是:您看到网格中的空行与第二个数据表中的行一样多.

The symptom of this is: you see as many empty row in the grid as there are rows in the second datatable.

原因: Gridcontrol (确切地说是gridview)已经具有 Columns 属性,并且找不到匹配的对.

Cause: Gridcontrol (gridview to be precise) already has Columns property and doesn't find matching pairs.

解决方案:加载第二个数据表后,调用 GridControl.PopulateColumns().这将重新创建 Colums 属性.

Solution: Call GridControl.PopulateColumns() after loading the second datatable. This will recreate Colums property.

  1. Gridview没有意识到基础数据源已更改.

症状:您看到的是旧值.

Symptom: you see old values.

解决方案:调用 GridView.Refresh()

据我从您的评论中可以看到,您遇到的是前一个问题.因此,以这种方式进行操作:

As far as I can see from your comments, you have the former issue. So, do something in this manner:

gridControl.DataSource = myFirstDataTable();

/* some other code*/ 

gridControl.DataSource = mySecondDataTable();
(gridControl.MainView as ColumnView).PopulateColumns()

这篇关于vb.net中的DevExpress刷新datagridview不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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