我试图将行添加到datagridview并在新行中写一些东西。接下来的任何添加都会删除预览行的内容

private void button1_Click(object sender, EventArgs e)
        {
            dataGridView2.RowCount = dataGridView2.RowCount + 1;
            dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[0].Value = "smth";


                dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[1].Value = "something";

        }

最佳答案

尝试这个

dataGridView2.Rows.Add("Smth","Something");

10-06 01:52