VB. NET
Private Sub BtNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtNext.ClickIf Me.BindingContext(Ds1, "工资表").Count = 0 Then
Exit Sub
End If
Dim i As Integer
i = Me.BindingContext(Ds1, "工资表").Count - 1
If Me.BindingContext(Ds1, "工资表").Position < i Then
Me.BindingContext(Ds1, "工资表").Position += 1
Me.txtlocationchange()
End If
DataGrid1.UnSelect(DataGrid1.CurrentRowIndex - 1)
Me.DataGrid1.Select(datagrid1.CurrentRowIndex)
End Sub
上段代码在运行时报错:索引超出了数组界限
特别是DataGrid1.UnSelect(DataGrid1.CurrentRowIndex - 1)这句
小妹急啊!快点回我啊?
--------------------编程问答-------------------- DataGrid1.UnSelect(DataGrid1.CurrentRowIndex - 1)
我们假设一下你的currentrowindex=0那么自然越界了。
try
DataGrid1.UnSelect(DataGrid1.CurrentRowIndex - 1)
catch ex as ...
end try
补充:VB , 基础类