# Re: dbgrid之addnew问题

Posted by 小琳 on August 22, 1999 at 22:43:12:

In Reply to: dbgrid之addnew问题 posted by adan on August 22, 1999 at 18:21:30:

: 如何用程式控制使dbgrid之箭头指标移至最下方addnew之那一列(有*号那一列,dbgrid之AllowAddNew属性已设为True),并使驻点在此列之第一格col,注意,是使用程式来移动,我试过用控制其连结之data控制项下addnew指令,但dbgrid指标还是不会移至那一列,用dogrid之row来控制,还是没办法将驻点(会一闪一闪之文字输入直条)移至有*号那一列,请问有人会吗?谢谢

:::关于您的问题，小女子让程式自己用Enter键来做就可以了
，程式如下：
Private Sub Command2_Click()
Dim i As Integer
Data1.Recordset.MoveLast
With DBGrid1
.Col = 0
.SetFocus
End With
For i = 1 To Data1.Recordset.Fields.Count
Call DBGrid1_KeyPress(13)
Next i
End Sub

Private Sub DBGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
With DBGrid1
If .Col = 1 Then
.Col = 0
.Row = .Row + 1
Else
.Col = .Col + 1
End If
End With
End If
End Sub

Follow Ups: