我有一个带有自动生成列Column = "true"
的Gridview
,现在我想在Gridview
的OnRowCreated
事件中更改列的位置。
我使用以下代码:
TableCell cell = e.Row.Cells[1];
TableCell cell1 = e.Row.Cells[0];
e.Row.Cells.RemoveAt(1);
e.Row.Cells.RemoveAt(0);
e.Row.Cells.Add(cell1);
e.Row.Cells.Add(cell);
它可以正常工作,将列0和1移动到网格视图的最后位置。
现在我想将GridView的第三列移动到第一列位置,所以我使用:
TableCell cell2 = e.Row.Cells[3];
e.Row.Cells.RemoveAt(3);
e.Row.Cells.AddAt(0, cell2);
但是它没有起作用...