小弟想写First、Previous、Next、Last四个按钮,来移动MSHFlexGrid的记录
请问是如何实现的啊?
[解决办法]
自己看看吧。
Option Explicit
Private Sub cmdFirst_Click()
MSFlexGrid1.Row = MSFlexGrid1.FixedRows
FixRest
End Sub
Private Sub cmdLast_Click()
MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
FixRest
End Sub
Private Sub cmdNext_Click()
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
FixRest
End Sub
Private Sub cmdPrevious_Click()
MSFlexGrid1.Row = MSFlexGrid1.Row - 1
FixRest
End Sub
Private Sub Form_Load()
Dim i As Integer
MSFlexGrid1.Rows = MSFlexGrid1.FixedRows
MSFlexGrid1.AllowBigSelection = False
MSFlexGrid1.RowSel = MSFlexGrid1.Row
MSFlexGrid1.FocusRect = flexFocusNone
For i = 1 To 20
MSFlexGrid1.AddItem i & vbTab & "Item " & i
Next
cmdFirst_Click
MSFlexGrid1_RowColChange
End Sub
Sub FixRest()
MSFlexGrid1.Col = 0
MSFlexGrid1.ColSel = MSFlexGrid1.Cols - 1
MSFlexGrid1.RowSel = MSFlexGrid1.Row
MSFlexGrid1.TopRow = MSFlexGrid1.Row
End Sub
Private Sub MSFlexGrid1_RowColChange()
cmdFirst.Enabled = (MSFlexGrid1.Row > MSFlexGrid1.FixedRows)
cmdPrevious.Enabled = cmdFirst.Enabled
cmdLast.Enabled = (MSFlexGrid1.Row < MSFlexGrid1.Rows - 1)
cmdNext.Enabled = cmdLast.Enabled
End Sub