List<C_Pinpai> lc;// = new List<C_Pinpai>(); private void BindGrid() { //if (lc.Count > 0) // lc.Clear(); lc = new List<C_Pinpai>(); if (Xml_Data.CoreDS.Tables["Product"].Rows.Count > 0) { foreach (DataRow dr in Xml_Data.CoreDS.Tables["Product"].Rows) { C_Pinpai c_pinpai = new C_Pinpai(); c_pinpai.Id = int.Parse(dr["id"].ToString()); c_pinpai.Isselect = false; c_pinpai.PinpaiInfo = dr["productinfo"].ToString(); c_pinpai.IsCanUse = dr["iscanuse"].ToString(); lc.Add(c_pinpai); } // MessageBox.Show(Xml_Data.CoreDS.Tables["Product"].Rows.Count.ToString()); cDataGridView1.DataSource = lc; } cDataGridView1.Refresh(); }
这样子就是OK的,如果不NEW一个出来,CLear是没用的,界面根本不动
虽然messagebox。show的时候数量在增加但是界面不动,搞不懂为什么,还是new一个吧
时间: 2024-10-17 04:55:43