gpt4 book ai didi

c# - datagridview 添加行

转载 作者:太空宇宙 更新时间:2023-11-03 16:28:42 25 4
gpt4 key购买 nike

我的表单上有一个简单的数据 GridView 。我添加了两列——一列是按钮类型,另一列是文本类型。我正尝试添加一些行作为测试,但我没有看到它们。

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

   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);

关于c# - datagridview 添加行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11604106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com