winfrom中datagrid排序

delectation 2008-10-23 05:03:20
在winform
定义了一个实体,加到List<Customer>中,然后绑定的DataGrid中,可为什么不能排序呢??
...全文
84 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
delectation 2008-10-24
  • 打赏
  • 举报
回复
Customer类实现了Icomparable接口了,就是比较实体中的一个字段
public int CompareTo(object obj)
{
Customer other = obj as Customer;
return String.Compare(this.Name, other.Name, false);
}
可还是无法排序呀。
delectation 2008-10-23
  • 打赏
  • 举报
回复
public int CompareTo(object obj)
{
Customer other = obj as Customer;
return String.Compare(this.Name, other.Name, true);
}
delectation 2008-10-23
  • 打赏
  • 举报
回复
Customer类实现了Icomparable接口了,就是比较实体中的一个字段。
enihs 2008-10-23
  • 打赏
  • 举报
回复
楼上正解
superxiaomm 2008-10-23
  • 打赏
  • 举报
回复
Customer类实现了Icomparable接口了没有?
guest78978 2008-10-23
  • 打赏
  • 举报
回复
((DataTable)dataGrid1.DataSource).DefaultView.Sort ="orderid";
dataGrid1.Refresh();

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧