禁用列标题中的DataGridView排序的最佳方法 [英] Best way to disable the column header sorting in DataGridView

查看:917
本文介绍了禁用列标题中的DataGridView排序的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要禁用列标题中的DataGridView 排序。

I need to disable the column header sorting in DataGridView.

我们可以做到这一点通过设置各列的属性如

We can do that by setting the property of individual columns like

BalancesGridView.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;

如果是这样的话,那么我会在所有的列具有循环。

If this is the case , then I'll have to loop through all the columns.

有没有更好的办法?

推荐答案

没有,我想设置在列的SortMode直接是因为它得到很好的。但说实话,谁在乎呢?这有什么不好一个简单的循环?

No, I think setting the SortMode on the column directly is as good as it gets. But honestly, who cares? What's so bad about a simple loop?

这篇关于禁用列标题中的DataGridView排序的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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