大概如下:执行类似的记录集操作 if datagrid.recordset.eof then datagrid.recordset.movelast end if
下面是我以前用过的,但今天调试时总是移一行不行,隔行反而,请你再调试调试 If KeyCode = vbKeyDown Then Adodc1.Recordset.MoveNext With DataGrid1 .SetFocus .Refresh End With ElseIf KeyCode = vbKeyUp Then Adodc1.Recordset.MovePrevious With DataGrid1 .SetFocus .Refresh End With End If
if datagrid.recordset.eof then
datagrid.recordset.movelast
end if
Adodc1.Recordset.MoveNext
With DataGrid1
.SetFocus
.Refresh
End With
ElseIf KeyCode = vbKeyUp Then
Adodc1.Recordset.MovePrevious
With DataGrid1
.SetFocus
.Refresh
End With
End If
你先将Datagrid1.AllowArrows和。WrapCellPointer两个属性都设置为True(代码设置也可以)。 这样就可以任何移动光标键了,但文本字段区不能移动(数字字段区能够移动),不知道是什么道理。
我们这里的有人是使用文本框来做的,先得当前Datagrid1的行列位置,使用一个文本去掩盖那个位置,用它来代替输入及接受焦点,刷新后再更新到数据库。