读书人

[]DataGrid控件有关问题

发布时间: 2012-03-08 13:30:13 作者: rapoo

[求助]DataGrid控件问题。
本人用DataGrid控件显示了一个数据表,想试用点击“下一页”来控制表中左边的光标随之向下移动。部分代码如下。

VB code
  with rs                 Case Is = 2                        .MoveNext                        If .EOF Then                            MsgBox "记录已到尾!", , "提示"                            .MoveLast                          End If                        If DataGrid1.Row = rs.RecordCount - 1 Then                            DataGrid1.Row = rs.AbsolutePosition                            End If                        If DataGrid1.Row < rs.RecordCount - 1 Then                            DataGrid1.Row = DataGrid1.Row + 1                            End If


运行了以后可以实现这个功能,但是当到达最后一个的时候就会出错,显示“行号无效”。而且我这个条件的分点也有问题。

请高人帮小弟指点一下。。谢谢。!

[解决办法]
with rs
Case Is = 2'这是什么意思,看不懂
.MoveNext

If .EOF Then
MsgBox "记录已到尾!", , "提示"

.MoveLast
End If

'注释掉的语句似乎不需要,因为Movenext等命令会自动移到和DataSource对应的当前记录
' If DataGrid1.Row = rs.RecordCount - 1 Then

' DataGrid1.Row = rs.AbsolutePosition

' End If

' If DataGrid1.Row < rs.RecordCount - 1 Then

' DataGrid1.Row = DataGrid1.Row + 1

' End If

读书人网 >VB

热点推荐