Dim i As integer = 0
while i < 10
gridview.RowCount = gridview.RowCount + 1
gridview.Row(i).Cells(0) = i
i++
End while
每次我通过上面的代码添加新行时,我想增加网格视图计数。但它只更新行,但它会跳过数据网格视图中的现有行。所以放在最后一排。
答案 0 :(得分:2)
不确定你想做什么。您始终可以将行数计为 gridview.rowcount - 1
下面的代码会将第一列单元格重命名为行序列0,1,2,3 ....
Dim rowcount as integer = gridview.RowCount - 1
Dim i As integer
for i = 0 to rowcount
gridview.Row(i).Cells(0) = i
next
答案 1 :(得分:1)
gridview.AllowUserAddRows = false
Dim i As integer = 0
while i < 10
gridview.RowCount = gridview.RowCount + 1
gridview.Row(i).Cells(0) = i
i++
End while
&#13;
这是在我刚刚登上顶峰后工作的 &#39; gridview.AllowUserAddRows = false&#39;