DataGridView的:如何选择整列并取消一切? [英] DataGridView: How to select an entire Column and deselect everything else?
本文介绍了DataGridView的:如何选择整列并取消一切?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在试图找出如何选择一列下的所有细胞的一个鼠标右键菜单+ +选择此列'......
I've been trying to find out how to select all cells under a Column with a 'mouse right click+menu+Select this Column'...
MSDN是不是帮助了...
MSDN isn't helping much...
我,当我试图改变选择模式得到这个错误:
I get this error when I try to change selection mode:
DataGridView control's SelectionMode cannot be set to FullColumnSelect while it has a column with SortMode set to DataGridViewColumnSortMode.Automatic.
谢谢,
Y_Y
Thanks, Y_Y
推荐答案
遍历列的单元格,并设置其Selected属性为true。结果
这听起来很可怕,但我相信这是选择一整列的唯一途径, 。保持自动分拣
Loop through the cells in the column and set their Selected property to true.
It sounds horrible, but I believe it's the only way to select an entire column and keep automatic sorting.
例如:
grid.ClearSelection();
for(int r = 0; r < grid.RowCount; r++)
grid[columnIndex, r].Selected = true;
这篇关于DataGridView的:如何选择整列并取消一切?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文