datagridview添加行

问题描述:

我在窗体上有一个简单的datagridview。我添加了2列 - 一个按钮类型和另一个文本类型。我正在尝试添加一些行,但我没有看到它们。datagridview添加行

以下是代码。这一定很简单,但我需要做什么才能看到我的新行?

private void Form1_Load(object sender, EventArgs e) 
    { 
     dataGridView1.Rows.Clear(); 
     DataGridViewRow newRow = new DataGridViewRow(); 
     Button button = new Button(); 
     button.Name = "BUTTON"; 
     button.Text="BUTTON"; 
     newRow.SetValues(button, "TEST"); 
     dataGridView1.Rows.Add(newRow); 

    } 

这似乎我同样的问题。我仍在阅读,看看他们发现了什么。

Why can't I see the DataGridViewRow added to a DataGridView?

一种解决方案似乎是在创建后调用该行CreateCells。

 newRow.CreateCells(dataGridView1);