当数据源绑定到List(Of T)时对Datagridview列进行排序 [英] Sort Datagridview columns when datasource binded to List(Of T)

查看:161
本文介绍了当数据源绑定到List(Of T)时对Datagridview列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a datagridview with its datasource binded to a List(Of T). Now i would like to sort on any of the columns.

我的代码:

'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


推荐答案

看看这个例子建议使用BindingList,然后使用一些代码来启用排序。关于codeproject还有

这篇关于当数据源绑定到List(Of T)时对Datagridview列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆