简体   繁体   English

如何在 C# 中使用冒泡排序或任何其他排序算法对 dataGridView 数据进行排序?

[英]How do i sort dataGridView data using bubble sort or any other sorting algorithm in C#?

This is the populated data in gridview Image That Shows The DataGridView这是显示 DataGridView 的 gridview 图像中的填充数据

Now, when i click the button2 the values should be sorted according to total earing from highest to lowest.现在,当我单击按钮 2 时,应根据总耳数从最高到最低对值进行排序。 How do i do that?我怎么做?

You can call你可以打电话

yourdatagridview.Sort(yourdatagridview.Columns["name_of_total_earning_column_here"], ListSortDirection.Descending);

..footnote that the underlying data will need to be numeric for it to work "properly". ..footnote 基础数据需要是数字才能“正常”工作。 If total earning is a string you'll see 20, 2, 11, 10, 1 etc如果总收入是一个字符串,您将看到 20、2、11、10、1 等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM