【问题标题】:How to add rows and columns to a DataGrid?如何向 DataGrid 添加行和列?
【发布时间】:2011-05-14 23:24:39
【问题描述】:

如何向 DataGrid 添加行和列?

我正在尝试编写两个函数,例如:

public void addRow(DataGrid grid);
public void addColumn(DataGrid grid);

很遗憾,DataGrid 本身默认没有这些功能。

非常感谢。

【问题讨论】:

  • 是关于 WPF/Silverlight DataGrid 的吗?
  • 不,是关于 System.Windows.Forms.DataGrid

标签: c# winforms .net-4.0 datagrid


【解决方案1】:

我最近对 ​​DataGrid 做的不多,但据我所知,DataGrid 有一个数据源,它是应该在代码中扩展的数据源。

扩展数据源(如数据表)后,您应该刷新数据网格。

【讨论】:

    【解决方案2】:

    This 链接提供有关如何将行添加到数据网格的信息

    【讨论】:

      【解决方案3】:

      默认没有这些功能?怎么样:

      dataGrid.Columns.Add
      

      【讨论】:

      猜你喜欢
      • 2014-09-11
      • 2014-02-03
      • 1970-01-01
      • 2011-08-07
      • 2018-04-11
      • 2022-08-18
      • 2021-10-20
      • 2016-11-09
      • 1970-01-01
      相关资源
      最近更新 更多