datagrid问题
我使用vb的datagrid来进行数据库的插入修改,我想在修改一个记录后按回车直接跳到下一行,如果当前是最后一行默认进行添加记录操作,请高手帮帮忙。。。 --------------------编程问答-------------------- 如果是添加记录按回车进行添加下一个 --------------------编程问答-------------------- 绑定adode控件就可以实现 --------------------编程问答-------------------- 绑定adode控件就可以实现 --------------------编程问答--------------------给你点代码自己改改吧,
Private Sub DataGrid1_Click()
With DataGrid1
Text2.Visible = True
If .Col < 0 Then Exit Sub
If .Row < 0 Then Exit Sub
a = .Row: b = .Col
Text2.Move .Columns(.Col).Left + .Left, .RowTop(.Row) + .Top, .Columns(.Col).Width, .RowHeight
Text2.BackColor = &HC0FFC0
Text2 = ""
Debug.Print .Columns(.Col).CellText(.RowBookmark(.Row))
If .Columns(.Col).CellText(.RowBookmark(.Row)) = "" Then
Text2.Text = ""
Else
Text2.Text = .Columns(.Col).CellText(.RowBookmark(.Row))
End If
Text2.SelLength = Len(Text2.Text)
Text2.SetFocus
End With
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii <> 13 Then Exit Sub
If Text2.BackColor = &HC0FFC0 Then
Text2.Visible = False
DataGrid1.SetFocus
DataGrid1.SelStartCol = b
DataGrid1.SelStart = 0
DataGrid1.SelLength = Len(DataGrid1.Columns(b).CellText(DataGrid1.RowBookmark(a)))
DataGrid1.Text = Text2.Text
End If
End Sub
补充:VB , 控件