dataGRIDVIEW 绑定不刷新  每隔1秒我就会刷新数据, 如果有新数据, 我就会DATAGRIDVIEW.SOURCE= list;但是不会刷新数据。 因为我是从数据库里读出数据,然后再解析数据,最后存到list里。
用LIST来绑定。

解决方案 »

  1.   

    检查一下list是否正确,是新数据否。或是执行一次DataGridView的Select之类的方法刷新一下?
      

  2.   


    list 里是有数据的,count 已经更新。就是显示不出来。
      

  3.   

      没有,   //填充数据,将数据库里的数据读取出来并解析放放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];
                }
                       }
      

  4.   

    调试的时候,datagrid.rows.count 都是有值的,数据也是有的。
      

  5.   

    DeviceMangement_Load(sender, e);你换成直接绑定的试试!
      

  6.   


    找到问题了, 是用list的问题。 不刷新是因为绑定的数据源是List<T>的类型  dataGrid.DataSource = ldevInfo.ToArray(); 就可以了。