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(); 就可以了。 文本框变灰色,不可输入 请问如何实现窗体载入加显示进度条? IE打印问题没有人能解决吗? 如何通过dataview来实现检索部分列 VS2010中C#如何使用报表? 关于接口的疑问??? winform项目属性问题 如何将不在同一命名空间的对象序列化 我准备2003年春节创办一个软件公司,敬请有软件创业经验的人提点参考意见。 用C#倒底能做什么???????????????? 如果同时装有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(); 就可以了。