Reputation: 69
I have a MainPanel
which contains myElement
. When I press the mouse button on the panel, and move it over myElement
while still holding the button, myElement_MouseMove
does not get called.
private void myElement_MouseMove(object sender, MouseEventArgs e)
{
myElementStatus_lbl.Text = "I SEE YOU";
}
It works when I'm not holding the mouse button down.
How do I detect mouse movement when the mouse button is down?
this.MainPanel.Controls.Add(this.myElement);
this.MainPanel.Location = new System.Drawing.Point(182, 84);
this.MainPanel.Name = "MainPanel";
this.MainPanel.Size = new System.Drawing.Size(604, 309);
this.MainPanel.TabIndex = 0;
//
// myElement
//
this.myElement.Location = new System.Drawing.Point(220, 67);
this.myElement.Name = "myElement";
this.myElement.Size = new System.Drawing.Size(200, 100);
this.myElement.TabIndex = 0;
Upvotes: 5
Views: 2281
Reputation: 22617
I think its because drag events occur during mouse pressed. So when your holding the mouse button and the mouse enters a control, drag enter event takes place.
You can detect mouse movements using one of the drag events. DragEnter, DragOver, DragLeave.
Edit: DoDragDrop disables MouseMove Events
Upvotes: 5