【问题标题】:how to add row to datagridview如何将行添加到datagridview
【发布时间】:2009-10-08 09:56:04
【问题描述】:

如何添加返回我查询结果的 tableadapter 行(此查询只返回一行)。

我需要将所有这些行添加到 datagridview(在 for 循环期间)

【问题讨论】:

    标签: c#


    【解决方案1】:

    DataGridView 上有 DataSource 属性。您可以将从您的 DataAdapter(DataTable?)返回的结果设置为该属性。

    DataGridView.DataSource

    【讨论】:

    • /我同意。使用 DataSource 属性,然后将行添加到数据源而不是 DataGridView,然后刷新绑定。这通过使用 BindingSource 对象变得更容易。将您的数据源(可数据源或其他)设置为 BindingSource 的数据源。然后将DataGridView 的DataSource 设为BindingSource。然后刷新绑定,您只需调用 BindingSource.RefreshBindings()。
    猜你喜欢
    • 1970-01-01
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 2022-01-25
    • 1970-01-01
    相关资源
    最近更新 更多