【问题标题】:Datagridview doesnt show any dataDatagridview 不显示任何数据
【发布时间】:2016-12-29 13:06:19
【问题描述】:

我正在使用绑定源控件在 winforms 应用程序中加载 datagridview。我使用列表加载绑定源控件,并将绑定源作为 datagridview 的数据源。当我运行代码时,datagridview 中没有加载数据。谁能帮我 ?我为此编写的代码如下所示。`

 private void SetData(ListAirport la, string iata)
    {
        itemBindingSource.DataSource = la;

        dgvItemDetails.DataSource = itemBindingSource;
    }

有趣的是,当我取 itemBindingSource.Count 时,它显示 556 和 dgvItemDetails.Rows.Count 为 0

【问题讨论】:

    标签: c# datagridview datasource bindingsource


    【解决方案1】:

    使用这个:

        dgvItemDetails.DataSource = itemBindingSource;
        dgvItemDetails.DataBind();//You need to bind it to the control
    

    【讨论】:

    【解决方案2】:

    您的 DataGridView 似乎不知道如何绑定到 ListAirport。您要做的是将其转换为 DataTable。

    【讨论】:

      猜你喜欢
      • 2011-06-26
      • 2011-07-31
      • 2016-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多