Search code examples
vb.netgridviewcomponentone

How to avoid gridview mouse leave event when clicking on vertical scrollbar?


I have a form with a floating gridview that must appear when filling a textbox or clicking on a button. If item selected or mouse leaving grid, grid becomes invisible so user can see rest of the form. Grid data most cases exceed maximum vertical size, so a vertical scrollbar is needed. My problem is that when mousing to vertical scrollbar triggers MouseLeave event, so grid becomes invisible.

This time I think it's not a code matter, so is there some property to change to make the program identify vscrollbar as part of the GridView? Or else is there some code solution to ignore MouseLeave event when mousing to scrollbar?

Here is my event code, pretty simple:

Private Sub GridCliente_MouseLeave(sender As Object, e As System.EventArgs) Handles GridCliente.MouseLeave
    GridCliente.Visible = False

End Sub

Also, I'm using Component One C1TrueDBGrid instead of standard gridview. It may be important.


Solution

  • I found a solution to my problem by adding the GridView to a panel and changing the MouseLeaveevent to the panel. For this to work, the panel must exceed the GridView size at least one pixel each side, since MouseLeave will not trigger if GridView is the same size of the panel (you must mouse over the panel and not any other component inside it to have vb.net consider mouse inside panel). Maybe it's not the best solution but it works for me.