DataGridViewColumn初始排序方向 [英] DataGridViewColumn initial sort direction

查看:236
本文介绍了DataGridViewColumn初始排序方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VS2008在C#WinForms应用程序上工作。默认情况下,当单击DataGridView中的列标题时,会将该列排序为Ascending,然后可以再次单击列标题对其进行排序。



我试图扭转这一点,所以初始点击排序降序,然后第二次点击排序升序,我无法弄清楚如何做到这一点。有人知道吗?



谢谢

解决方案

您可以设置HeaderCell将SortGlyphDirection转到Ascending,然后点击下一步就会降序。默认值为none。

  dataGridView1.Sort(Column1,ListSortDirection.Ascending); 
this.Column1.HeaderCell.SortGlyphDirection = System.Windows.Forms.SortOrder.Ascending;


I'm working in VS2008 on a C# WinForms app. By default when clicking on a column header in a DataGridView it sorts that column Ascending, you can then click on the column header again to sort it Descending.

I am trying to reverse this, so the initial click sorts Descending then the second click sorts Ascending and I haven't been able to figure out how to do this. Does anyone know?

Thanks

解决方案

You can set the HeaderCell SortGlyphDirection to Ascending, and then the next click will give you the descending order. The default is none.

dataGridView1.Sort(Column1, ListSortDirection.Ascending);
this.Column1.HeaderCell.SortGlyphDirection = System.Windows.Forms.SortOrder.Ascending;

这篇关于DataGridViewColumn初始排序方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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