日期:2014-05-20  浏览次数:20661 次

dataGridView
   private void dataBind(Object dataObject) 
        {
            list = cargoBll.Select_SId(num);
            list1 = commod.getTakeCommodityInfo();
            System.Windows.Forms.DataGridView dv = (DataGridView)dataObject;

            int i =0;
            foreach (CargoInfo car in list)
            {  
                    dv[0, i].Value = car.CId;
                    dv[1, i].Value = car.CargoNames;
                    dv[2, i].Value = car.Unit;
                    dv[8, i].Value = car.IsGift;
                    dv[9, i].Value = car.ShutDow;
                    i++; 
            }
            int n = 0;
            foreach(TakeCommodityInfo t in list1)
            {
                
                dv[3, n].Value = t.BeforeQty;
                dv[4, n].Value = t.BeforeAmnt;
                dv[5, n].Value = t.AfterQty;
                dv[6, n].Value = t.AfterAmnt;
                dv[7, n].Value = t.DiffeAmnt;
                dv[10,n].Value = t.Remark;
                n++;
            }
        }
索引超出范围
------解决方案--------------------
调试
监视
。。。
------解决方案--------------------
调试,显示索引超出范围了,请问;用dv[indexcloum,indexrow]这方式,怎么解决?
------解决方案--------------------
凡是带[]的,自己好好检查,别越界,记住下标从 0 开始
------解决方案--------------------
引用:
调试,显示索引超出范围了,请问;用dv[indexcloum,indexrow]这方式,怎么解决?