【问题标题】:datagridview add rowsdatagridview 添加行
【发布时间】:2012-07-22 21:27:41
【问题描述】:

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

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

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

    }

【问题讨论】:

    标签: c# winforms datagridview


    【解决方案1】:

    这似乎是我同样的问题。我仍在阅读以了解他们的发现。

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

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

         newRow.CreateCells(dataGridView1);
    

    【讨论】:

      猜你喜欢
      • 2018-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多