dataGRIDVIEW 绑定不刷新 dataGRIDVIEW 绑定不刷新 每隔1秒我就会刷新数据, 如果有新数据, 我就会DATAGRIDVIEW.SOURCE= list;但是不会刷新数据。 因为我是从数据库里读出数据,然后再解析数据,最后存到list里。用LIST来绑定。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 检查一下list是否正确,是新数据否。或是执行一次DataGridView的Select之类的方法刷新一下? list 里是有数据的,count 已经更新。就是显示不出来。 没有, //填充数据,将数据库里的数据读取出来并解析放放list if (showEvent.InitEventData(ldevInfo, envInfo) == 0) { dataGrid.ResetBindings(); dataGrid.DataSource = ldevInfo; } //刷新数据 private void timer1_Tick(object sender, EventArgs e) { int tempIndex = 0; if (dataGrid.Rows.Count > 0) { tempIndex = this.dataGrid.CurrentRow.Index; } DeviceMangement_Load(sender, e); if (dataGrid.Rows.Count > 0) { this.dataGrid.CurrentCell = this.dataGrid.Rows[tempIndex].Cells[1]; } } 调试的时候,datagrid.rows.count 都是有值的,数据也是有的。 DeviceMangement_Load(sender, e);你换成直接绑定的试试! 找到问题了, 是用list的问题。 不刷新是因为绑定的数据源是List<T>的类型 dataGrid.DataSource = ldevInfo.ToArray(); 就可以了。 pda wifi连接的问题 C#读取XML 请大家帮忙看下代码 求教算法 vs 2003 windowsform 中,如何设置datagrid单元格字体颜色和背景颜色? C# 我在winform 里面加入的键盘按下事件怎么无效 如何用代码实现TextBox值的绑定呀? 更新数据库时当变量包含“'”时会出错的问题 请问关于DataGridView绑定的问题? 答对立马给分 如果同时装有sql2008和sql2005,那么连接时如何选择。 继承就有运行代码了?
list 里是有数据的,count 已经更新。就是显示不出来。
if (showEvent.InitEventData(ldevInfo, envInfo) == 0)
{
dataGrid.ResetBindings();
dataGrid.DataSource = ldevInfo;
} //刷新数据
private void timer1_Tick(object sender, EventArgs e)
{
int tempIndex = 0;
if (dataGrid.Rows.Count > 0)
{
tempIndex = this.dataGrid.CurrentRow.Index;
}
DeviceMangement_Load(sender, e);
if (dataGrid.Rows.Count > 0)
{
this.dataGrid.CurrentCell = this.dataGrid.Rows[tempIndex].Cells[1];
}
}
找到问题了, 是用list的问题。 不刷新是因为绑定的数据源是List<T>的类型 dataGrid.DataSource = ldevInfo.ToArray(); 就可以了。