Need MouseEnter to work when left mouse is down

Hello Folks:

I have an event handler for Mouse Enter events.  It's pretty generic.
    Private Sub textboxBoggleDie00_MouseEnter(ByVal pSender As Object, ByVal e As System.EventArgs) _
    Handles textboxDie00.MouseEnter, _
                textboxDie01.MouseEnter, _
                textboxDie02.MouseEnter

        Dim Sender As Integer

        If LeftMouseDown Then
            Sender = Me.DieIndex(pSender.Name)
            Me.MouseEvent(Sender)
        Else
        End If

    End Sub

This works great if no mouse buttin is down as the mouse moves along.   But if the mouse is moved with the left mouse buttoin down, I never get control.
 
How can I get the mouse enter event to work with buttons down?
jflannerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Something like this:

    Private Sub Button1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove
        If e.Button = MouseButtons.Left Then
            ' mouse has moved in control while the left button was down
        End If
    End Sub

~IM
0
jflannerAuthor Commented:
Hi Idle Mind:

This did not do the trick.  It behaves just as the MouseEnter did.  That is, I get control if the mouse moves within a textbox, and both mouse buttons are up.  I do not get control if either mouse button is down.

One weird thing - I do get control if I move around in the same control I left downed in.  But if I left down in another control, and move into the control with left mouse down, I do not get control.  (I prove this in the code below by setting a break point on the statement Sender = Me.DieIndex(pSender.Name).  Notice the IF structure I have surroinded htis with.)

My goal is to get control if the mouse enters the testbox while the mouse button is depressed.

My code is below.  Any more iseas???

    Private Sub MouseMove(ByVal pSender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles textboxBoggleDie00.MouseMove, _
                textboxBoggleDie01.MouseMove, _
                textboxBoggleDie02.MouseMove, _
                textboxBoggleDie03.MouseMove, _
                textboxBoggleDie10.MouseMove, _
                textboxBoggleDie11.MouseMove, _
                textboxBoggleDie12.MouseMove, _
                textboxBoggleDie13.MouseMove, _
                textboxBoggleDie20.MouseMove, _
                textboxBoggleDie21.MouseMove, _
                textboxBoggleDie22.MouseMove, _
                textboxBoggleDie23.MouseMove, _
                textboxBoggleDie30.MouseMove, _
                textboxBoggleDie31.MouseMove, _
                textboxBoggleDie32.MouseMove, _
                textboxBoggleDie33.MouseMove

        Dim Sender As Integer


        If e.Button = MouseButtons.Left Then
            'GARBAGE IF: limit to textboxBoggleDie00 for debugging
            If pSender.Name = "textboxBoggleDie00" Then
                'BREAK POINT SET HERE.
                Sender = Me.DieIndex(pSender.Name)
                Me.MouseEvent(Sender)
            Else
            End If
        Else
        End If

    End Sub
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
You need to handle it via Drag and Drop operations.  The following will detect when the mouse moves in TextBox2 after you initiate the drag with the left button down in TextBox1:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.AllowDrop = True
        TextBox2.AllowDrop = True
    End Sub

    Private Sub TextBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove
        If e.Button = MouseButtons.Left Then
            TextBox1.DoDragDrop(TextBox1.Text, DragDropEffects.Copy Or DragDropEffects.Move)
        End If
    End Sub

    Private Sub TextBox2_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter
        If (e.Data.GetDataPresent(DataFormats.Text)) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub

    Private Sub TextBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragOver
        Debug.WriteLine("TextBox2_DragOver@ (" & e.X & ", " & e.Y & ")")
    End Sub

    Private Sub TextBox2_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
        TextBox2.Text = e.Data.GetData(DataFormats.Text).ToString
    End Sub

End Class
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.