VB 6.0 中 DataGrid 怎么样定位到最后一行
VB+ACCESSDataGrid问题:用定时器控制,每2秒向数据库中添加一条数据,新增的数据马上在DataGrid显示出来,上面的都没问题。现在实现不了的是:要求Dat...
VB+ACCESS DataGrid问题:用定时器控制,每2秒向数据库中添加一条数据,新增的数据马上在DataGrid显示出来,上面的都没问题 。现在实现不了的是:要求DataGrid光标定位在新增加的数据那一行。。也就是说每新增一条数据,DataGrid光标就马上定位到新增的数据那一行
Private Sub Timer3_Timer()
'Dim x as Long
'Dim y As Long
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = F:\伺服电机\电机测试台软件\软件1\简易通讯软件\dj.mdb"
conn.CursorLocation = adUseClient
conn.Open
rs.Open "select * from sjb", conn, adOpenKeyset, adLockOptimistic
rs.AddNew
'x = DataGrid1.Row
'y = DataGrid1.Col
rs.Fields("电压") = Val(Text1(0).Text)
rs.Fields("电流") = Val(Text1(1).Text)
rs.Fields("输入功率") = Val(Text1(2).Text)
rs.Fields("转速") = Val(Text1(6).Text)
rs.Fields("转矩") = Val(Text1(5).Text)
rs.Fields("输出功率") = Val(Text1(7).Text)
rs.Fields("效率") = Val(Text1(8).Text)
rs.Update
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
'rs.MoveLast
'rs.MoveNext
'Set DataGrid1.DataSource = Nothing
'DataGrid1.Refresh
'DataGrid1.Row = x + 1
'DataGrid1.Col = y
rs.Close
Set conn = Nothing
End Sub 展开
Private Sub Timer3_Timer()
'Dim x as Long
'Dim y As Long
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = F:\伺服电机\电机测试台软件\软件1\简易通讯软件\dj.mdb"
conn.CursorLocation = adUseClient
conn.Open
rs.Open "select * from sjb", conn, adOpenKeyset, adLockOptimistic
rs.AddNew
'x = DataGrid1.Row
'y = DataGrid1.Col
rs.Fields("电压") = Val(Text1(0).Text)
rs.Fields("电流") = Val(Text1(1).Text)
rs.Fields("输入功率") = Val(Text1(2).Text)
rs.Fields("转速") = Val(Text1(6).Text)
rs.Fields("转矩") = Val(Text1(5).Text)
rs.Fields("输出功率") = Val(Text1(7).Text)
rs.Fields("效率") = Val(Text1(8).Text)
rs.Update
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
'rs.MoveLast
'rs.MoveNext
'Set DataGrid1.DataSource = Nothing
'DataGrid1.Refresh
'DataGrid1.Row = x + 1
'DataGrid1.Col = y
rs.Close
Set conn = Nothing
End Sub 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询