DataGridView添加行数据并赋值

                   //添加行数据                   
                    DataGridViewRow Row = new DataGridViewRow();
                    dataGridView1.RowHeadersWidth = 45;

                    int index = dataGridView1.Rows.Add(Row);
                    dataGridView1.Rows[index].Cells[0].Value = dr[0].ToString();
                    dataGridView1.Rows[index].Cells[1].Value = dr[1].ToString();

你可能感兴趣的:(DataGridView添加行数据并赋值)