Link to home
Start Free TrialLog in
Avatar of tmostad
tmostad

asked on

Intercept mouse_down event over DataGridView?

I've drawn a square (in the DGV_Paint sub) on top of a DataGridView control and when I click on it I don't want the underlying DataGridView to see the click event. Ideally there would be an e.handled property for mouse_down but there isn't. What I get is a cell_changed event in the DataGridView control which is causing me problems. There are some rather ugly ways around this but I am looking for something prettier.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
there is no cellchanged event in datagridview, what do you mean?

in case this helps,
Mouse events occur in the following order:

MouseEnter

MouseMove

MouseHover / MouseDown / MouseWheel

MouseUp

MouseLeave

Avatar of tmostad
tmostad

ASKER

Sorry, I meant CurrentCellChanged event. I used that event to do stuff when the user actually wants to change cells not when the square above the DGV is clicked.
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
        If DataGrid1.MouseButtons = MouseButtons.Left Then
            MsgBox("left mouse button pressed")
        End If
End sub