绑定数据总结

来源:互联网 发布:instagram网络未知错误 编辑:程序博客网 时间:2024/05/22 17:48
解决反向的显示的问题

在datagridview事件DataBindingComplete添加代码
反向修改
 listXuanBie2 = (List<TSMES.Model.FORMATION_TRAY_OKNG>)dtOKNG.DataSource;
            //status
            foreach (DataGridViewRow row in dtOKNG.Rows)
            {
                if (listXuanBie2[row.Index].status == 1)
                {
                    row.Cells["status"].Value = "接收";
                }
                else if (listXuanBie2[row.Index].status == 0)
                {
                    row.Cells["status"].Value = "初始值";
                }
                else if (listXuanBie2[row.Index].status == 2)
                {
                    row.Cells["status"].Value = "完成";
                }
                else if (listXuanBie2[row.Index].status == 3)
                {
                    row.Cells["status"].Value = "错误";
                    row.Cells["status"].Style.BackColor = Color.Red;
                }
               
               
            }

字段列表中也要修改字段,不要绑定数据源。

重新显示的时候
数据源一定要重新复制为NULL
0 0