C# DataGridView 的插入数据到第一行

188不打篮球 / 2023-05-08 / 原文

 DataGridViewRow dr = new DataGridViewRow();
            dr.CreateCells(dgv);
            //dr.Cells[0].Value = "h1";
            //dr.Cells[1].Value = (++c);
             dr.SetValues(body.Split(","));
            dgv.Rows.Insert(0, dr);     //插入的数据作为第一行显示

    //dgv.Rows.Add(dr);                    //插入的数据作为最后一行显示