且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在webform中重新排序网格视图列

更新时间:2023-10-04 22:56:28

TabIndex不会改变顺序GridView中的列。您可以在代码隐藏中修改Gridview的Columns集合,方法是从集合中的当前位置删除该列,然后将其重新插入新位置。



例如,如果您想将第二列移动到您可以执行的第一列:



TabIndex will not change the order of columns in your GridView. You can modify the Gridview's Columns collection in your code-behind by removing the column from its current position in the collection and then re-insert it into the new position.

For example, if you wanted to move the second column to be the first column you could do:

var columnToMove = GridView1.Columns[1];
GridView1.Columns.RemoveAt(1);
GridView1.Columns.Insert(0, columnToMove);