开发者

vb6 how to know msflexgrid_scroll up down click

when clicking on the msflexgrid scroll bar on the down arrow, how can i know that i have clicked on the down arrow. give me sam开发者_StackOverflow中文版ple code if possible.

Thanks


Depends on what you want it for (which defines how specific you need it to be). You can tell when the grid has been scrolled successfully with the Scroll event:

Private Sub MSFlexGrid1_Scroll()

    Debug.Print "Scrolled"

End Sub

If you need to distinguish down from up (and a single move from a larger bar-click move), you'll have to keep track of the top row:

Option Explicit
Public GridTop As Long

Private Sub Form_Load()
Dim lA As Long

    MSFlexGrid1.Cols = 4
    MSFlexGrid1.Clear
    For lA = 1 To 20
        MSFlexGrid1.AddItem lA & vbTab & "bob-" & lA & vbTab & lA & "-fred" & vbTab & lA & "-joe-" & lA
    Next lA
    MSFlexGrid1.RemoveItem 1
    GridTop = MSFlexGrid1.TopRow

End Sub

Private Sub MSFlexGrid1_Scroll()

    Debug.Print "Scrolled"
    Debug.Print MSFlexGrid1.TopRow
    If MSFlexGrid1.TopRow = GridTop + 1 Then
        Debug.Print "Down arrow (effective)"
    End If
    GridTop = MSFlexGrid1.TopRow

End Sub

If you actually need to know when you've clicked the down-arrow specifically, whether or not it actually scrolls the grid, now you're into subclassing. Try this:

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=59656&lngWId=1

Just swap out a flexgrid for rtfExample in the sample project - I tried it, seems to work fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜