BeforeMouseDown Event

Fired before the control processes the MouseDown event.

Syntax

Private Sub VSFlexGrid_BeforeMouseDown( ByVal Button As Integer,  ByVal Shift As Integer,  ByVal X As Single,  ByVal Y As Single, Cancel As Boolean)

Remarks

The parameters for this event are identical to the ones in the MouseDown event, plus an additional Cancel parameter that allows you to prevent the default processing.

This event is useful if you want to process some mouse actions yourself, instead of relying on the control's default processing.

For example, the following routine detects SHIFT-clicks and uses them to build and save a list of selected rows. Then it initiates a drag operation using Visual Basic's Drag method. The default mouse processing is canceled so the control does not modify the selection as the user drags the mouse.

Private Sub fa_BeforeMouseDown(ByVal Button As Integer, ByVal Shift As Integer, _

ByVal X As Single, ByVal Y As Single, Cancel As Boolean)

                    ' use SHIFT to drag (CTRL selects)

       If Shift <> 1 Then Exit Sub       

                    ' cancel remaining mouse events

                    Cancel = True             

                    ' build a list of what we'll be dragging

                    Dim i As Long              

                    fa.Tag = ""

        For i = 0 To fa.SelectedRows - 1

            fa.Tag = fa.Tag & vbCrLf & vbTab &    fa.Cell(flexcpText, fa.SelectedRow(i), 0)

        Next

        fa.Drag                     ' start dragging

    End Sub

See Also

VSFlexGrid Control