PropertyGrid.Refresh causes MouseMove

L

Lance

I've noticed that calling the Refresh method of a
PropertyGrid causes a MouseMove event to occur for the
control that owns the mouse. For example, if the mouse is
over PictureBox1 when PropertyGrid1.Refresh is called,
then PictureBox1.OnMouseMove will be invoked.

This behavior is causing major problems for me because I
am tring to update a PropertyGrid whenever the user
manipulates objects that are contained within a PictureBox
so that the PropertyGrid always reflects the current state
of the manipulated objects. But, doing this causes a
cascade of events to occur because PropertyGrid.Refresh is
called in PictureBox.OnMouseMove (i.e., after the objects
have been manipulated), but calling PropertyGrid.Refresh
causes another PictureBox.OnMouseMove to occur.

I have tried to set a flag in an inherited PictureBox that
suspends the PictureBox.OnMouseMove method while the
PropertyGrid is refreshing, but this doesn't work because
subsequent MouseMove events can occur before the
PropertyGrid finishes refreshing.

Any ideas?

Thanks,
Lance
 
P

Peter Huang

Hi Lance,

I can reproduce the problem.
But I am sorry that it seems that this is by design.
You may take a look at the link below.
Why do I get spurious WM_MOUSEMOVE messages?
http://blogs.gotdotnet.com/raymondc/PermaLink.aspx/d8afd9b1-06ec-4046-939d-d
dc4d7662ec2

To workaround the issue, you may try to evaluate if the mouse has moved.
e.g.

Shared var As Point
Private Sub test(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
If Not var.X = e.X Or Not var.Y = e.Y Then
Debug.WriteLine("hello")
End If
var.X = e.X
var.Y = e.Y
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
AddHandler PictureBox1.MouseMove, AddressOf test
Me.PropertyGrid1.Refresh()
End Sub

You may try to change the code as you need.

If you have any concern on this issue,please post here.


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
L

Lance

Thanks for the info. Your suggestion seems like the best
solution. It's nice to know that there isn't a more
direct fix.

Lance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top