DataGridView动态添加行

作者:追风剑情 发布于:2014-4-25 22:55 分类:C#

            DataGridViewRow firstRow = dataGridView1.Rows[0];
            dataGridView1.AllowUserToAddRows = false;//不显示带*号的行

              DataGridViewRow row;
            for (int i = 0; i < 10; i++)
            {
                row = firstRow.Clone() as DataGridViewRow;

                row.Cells[0].Value = i;
                row.Cells[1].Value = "tiankt";
                row.Cells[2].Value = "问题";
                row.Cells[3].Value = "答案0";
                row.Cells[4].Value = "答案1";
                row.Cells[5].Value = "答案2";
                row.Cells[6].Value = "答案3";
                row.Cells[7].Value = "正确答案";
                row.Cells[8].Value = i;

                dataGridView1.Rows.Add(row);
            }
dataview.png

 

 

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号