在HeaderClick上对DataGrid进行排序(DataGrid Sorting on HeaderClick)

编程入门 行业动态 更新时间:2024-10-09 05:18:04
HeaderClick上对DataGrid进行排序(DataGrid Sorting on HeaderClick)

是否可以将DataGrid排序限制为有限的列? 例如,如果我有第1,2和3列。我只希望在用户单击第1列和第2列的标题时对数据进行排序,并且在单击第3列的标题时不会发生任何事情。

另外,我如何获取当前已排序列的信息。

谢谢

Is it possible to restrict DataGrid sorting to limited columns? For example, If I have columns 1, 2 and 3. I only want data to sort when user clicks header of column 1 and 2 and nothing should happen when header of column 3 is clicked.

Also how can I get the information which column is currently sorted.

Thanks

最满意答案

即使它可能是重复的,我也可以提出问题+1。

每个DataGrid列都允许指定用户是否能够对列进行排序。

看看这个链接。

http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcolumn.canusersort%28v=vs.110%29.aspx

现在,为了禁用排序,只需将DataGridColumn.CanUserSort设置为false即可。

+1 from me for the question even though it is probably a duplicate.

Every DataGrid column allows to specify if user shall be able to sort the column.

Take a look at this link.

http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcolumn.canusersort%28v=vs.110%29.aspx

Now in order to disable sorting just set DataGridColumn.CanUserSort to false.

更多推荐

本文发布于:2023-04-29 10:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335568.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:HeaderClick   DataGrid   Sorting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!