首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

小弟想写First、Previous、Next、Last四个按钮,来移动MSHFlexGrid的记录,该怎么解决

2012-01-28 
小弟想写First、Previous、Next、Last四个按钮,来移动MSHFlexGrid的记录请问是如何实现的啊?[解决办法]自己看

小弟想写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

热点排行