天天看點

datagridview 手動添加行資料

我在做軟體模型界面時,通過功能按鈕觸發顯示的datagridview中,為了友善,需要一些資料,僅寫死資料就可以了,是以,不需要連接配接資料表,直接添加行就可以了。代碼如下:

int index = this.dataGridView1.Rows.Add();
        this.dataGridView1.Rows[index].Cells[0].Value = "1";
        this.dataGridView1.Rows[index].Cells[1].Value = "11";
        this.dataGridView1.Rows[index].Cells[2].Value = "1111";
        this.dataGridView1.Rows[index].Cells[3].Value = "11111";
        this.dataGridView1.Rows[index].Cells[4].Value = "111111";
        this.dataGridView1.Rows[index].Cells[5].Value = "1111111";
        this.dataGridView1.Rows[index].Cells[6].Value = "*-*";