在datagrid视图c#中单击列标题时选择整行。 [英] select entire row on clicking column header in datagrid view c#.
本文介绍了在datagrid视图c#中单击列标题时选择整行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Ex
=============== | ================== ============
= Col1标题| Col2标题|
=============== | ==============================
= A | 1 |
= B | 2 |
= C | 3 |
= | |
=============== | ============================= |
选择col1标题时,选择A,B,仅限C。不是1,2,3。
解决方案
遍历单元格并选择每个列单元格 -
grid.ClearSelection();
for ( int r = 0 ; r< grid。 RowCount ; r ++)
grid [columnIndex,r] .Selected = true;
Ex
===============|==============================
= Col1 Header| Col2 Header |
===============|==============================
= A | 1 |
= B | 2 |
= C | 3 |
= | |
===============|=============================|
While selecting col1 Header means, select A,B,C only. not 1,2,3.
解决方案
Loop through the cells and select each column cell -
grid.ClearSelection(); for(int r = 0; r < grid.RowCount; r++) grid[columnIndex, r].Selected = true;
这篇关于在datagrid视图c#中单击列标题时选择整行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文