【问题标题】:Sort Datagridview columns when datasource binded to List(Of T)数据源绑定到 List(Of T) 时对 Datagridview 列进行排序
【发布时间】:2011-06-21 10:58:59
【问题描述】:

我有一个 datagridview,其数据源绑定到 List(Of T)。现在我想对任何列进行排序。

我的代码:

'Database access : items = List(BlogPost)
dgBlogPosts.DataSource = items

'My BlogPost Class
Public Class BlogPost

    Public Property ID As Integer
    Public Property Title As String
    Public Property Content As String
    Public Property CreationDate As DateTime
    Public Property Rating As Decimal = 5.0

End Class

【问题讨论】:

  • datagridview 还是 gridview 还是 datagrid?
  • datagridview 如主题中所述。

标签: vb.net generics generic-list


【解决方案1】:

查看this 示例,该示例建议使用 BindingList 代替,然后使用一些代码来启用排序。 codeproject上还有this

【讨论】:

  • 谢谢,这正是我需要的!
猜你喜欢
  • 2017-05-18
  • 1970-01-01
  • 1970-01-01
  • 2010-12-14
  • 2011-08-19
  • 2013-10-24
  • 2010-09-12
  • 1970-01-01
  • 2011-05-26
相关资源
最近更新 更多