what event is this on the msflexgrid?-VBForums
Results 1 to 4 of 4

Thread: what event is this on the msflexgrid?

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,494

    what event is this on the msflexgrid?

    Have you noticed in Excel, you can drag the mouse across a column of numbers and the total of the numbers will appear at the bottom right of the excel page?

    YOu can also drag across a column of cells in the MSFlexgrid, but I don't know how to show a total. It isn't mouse down, because that would only show the first cell (I think) and the one in excel updates as the mouse moves over each new cell, so it must be some sort of mousemove event or cell select event.

    has anybody done this before?

    Thanks

    Wengang
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,494
    okay this actually works:

    Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    intStart = MSFlexGrid1.Row
    intEnd = MSFlexGrid1.RowSel
    If intEnd > intStart Then
    p = -1
    Else
    p = 1
    End If
    a = 0
    For t = intStart To intEnd Step p
    a = a + Val(MSFlexGrid1.TextMatrix(t, MSFlexGrid1.Col))
    Next t
    Label2.Caption = a
    End Sub
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  3. #3

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,494
    NOPE! That was really buggy, but this actually DOES work:

    Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    tNewSel = MSFlexGrid1.RowSel 'these are dimmed up top
    If tOldSel <> tNewSel Then
    tOldSel = tNewSel ' this is to kill noise
    If MSFlexGrid1.RowSel > MSFlexGrid1.Row Then 'to avoid the word step
    intStart = MSFlexGrid1.Row
    intEnd = MSFlexGrid1.RowSel
    Else
    intStart = MSFlexGrid1.RowSel
    intEnd = MSFlexGrid1.Row
    End If
    a = 0
    For d = intStart To intEnd
    a = a + Val(MSFlexGrid1.TextMatrix(d, MSFlexGrid1.Col))
    Next d
    Label2.Caption = a
    End If
    End Sub
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    37,112
    Just for info: there is also a SelChange event on the MSFlexGrid, but it doesnt update until mouseup

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.