【问题标题】:Using an (I)List<string> as the source for a DataColumn使用 (I)List<string> 作为 DataColumn 的源
【发布时间】:2009-12-01 10:26:44
【问题描述】:

我正在玩弄 .NET 提供的 DataGridView 控件。 到目前为止,我似乎无法将 (I)List 绑定到 DataColumn。 这可能吗?我应该怎么做?

【问题讨论】:

  • 您的代码的 sn-p 可以在这里提供帮助...
  • 没什么可展示的,我有一个列表,想将它绑定到一个 DataColumn 对象以用列表的内容填充它:

标签: c# list datagridview collections datacolumn


【解决方案1】:

我认为此链接将回答您的问题: Binding List to datagridview

如果您将List&lt;string&gt; 直接绑定到Datagridview,您将只获得列中字符串的长度,因为它是列表中每个字符串的唯一属性。您需要在字符串本身可用作属性的位置进行设置。所以 Datagridview.Datasource 将是封装 IList 的类的实例,Datagridveiw.Datamember 将被设置为返回字符串的属性。

【讨论】:

    【解决方案2】:

    也许你应该看看BindingList class

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-09
      • 2012-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-12
      • 1970-01-01
      • 2020-10-21
      相关资源
      最近更新 更多