如何在C#中的(datagrid)中对数据进行排序? [英] How to sort the data in (datagrid ) in C# ?

查看:171
本文介绍了如何在C#中的(datagrid)中对数据进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

It is my code

this.dataGrid1.Allowsort  (this .dataGridTextBoxColumn1,ListSortDirection.Descending );





我尝试过:



this.dataGrid1.Allowsort(此.dataGridTextBoxColumn1,ListSortDirection.Descending );



What I have tried:

this.dataGrid1.Allowsort (this .dataGridTextBoxColumn1,ListSortDirection.Descending );

推荐答案

你应该将Column SortMode 设置为 Programmatic 如下面的代码片段



You should set Column SortMode to Programmatic like in snippet below

dataGridView1.Columns[0].SortMode =  DataGridViewColumnSortMode.Programmatic;


这篇关于如何在C#中的(datagrid)中对数据进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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