我有一个 DataGridView 对象,我通过为其 DisplayIndex 属性分配特定值来重新排列它的列,例如:
grdMain.Columns["BarcodeNumber"].DisplayIndex = 0;
grdMain.Columns["Type"].DisplayIndex = 1;
grdMain.Columns["Title"].DisplayIndex = 2;
grdMain.Columns["ParentID"].DisplayIndex = 3;
在填充了DGV对象之后,我正在以这种方式重新排列列。
我的问题是:
例如,如果我从grdMain.Columns [“ BarcodeNumber”]列开始作为网格中的第五列(索引为4),然后重新分配该列的DisplayIndex属性为0,那么以下哪个将正确访问BarcodeColumn的值:
grdMain.Columns[0]
或者
grdMain.Columns[4]
更改DGV列的DisplayIndex是否会影响其在表格上的实际索引?
谢谢!