[英]DevExpress Refreshing datagridview in vb.net not working
DevExpress Refreshing datagridview in vb.net not working. vb.net中的DevExpress刷新datagridview不起作用。
I load one table from my database to datagridview and it display all the data 我从数据库中将一张表加载到datagridview,它显示所有数据
Problem - When I load another table from database to datagridview, It wasn't working. 问题 -当我将另一个表从数据库加载到datagridview时,它不起作用。 Only the first table will display its data while the second table won't display any data to datagridview. 只有第一个表将显示其数据,而第二个表将不显示任何数据到datagridview。
After you assign a new data source to the grid, call the GridView.PopulateColumns method to re-generate columns: 在将新的数据源分配给网格之后,请调用GridView.PopulateColumns方法以重新生成列:
gridControl1.DataSource = secondDataTable;
GridView gv = (GridView)gridControl1.FocusedView;
gv.PopulateColumns(secondDataTable);
There are two possible reasons for this kind of behavior: 这种行为有两个可能的原因:
The symptom of this is: you see as many empty row in the grid as there are rows in the second datatable. 其症状是:您在网格中看到的空行与第二个数据表中的行一样多。
Cause: Gridcontrol
(gridview to be precise) already has Columns
property and doesn't find matching pairs. 原因: Gridcontrol
(准确地说是gridview)已经具有Columns
属性,并且找不到匹配的对。
Solution: Call GridControl.PopulateColumns()
after loading the second datatable. 解决方案:加载第二个数据表后,调用GridControl.PopulateColumns()
。 This will recreate Colums
property. 这将重新创建Colums
属性。
Symptom: you see old values. 症状:您看到旧值。
Solution: Call GridView.Refresh()
解决方案:调用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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.