strange problem about PropertyGrid

G

Guest

I write a Vector Draw program.In my custom control,I override
OnMouseMove(...) in which I call PropertyGrid 's Refresh().Once OnMouseMove
invoke,even if I don't
move mouse.It'll generate WM_MouseMove continously(using spy to monitor it).

for example,there is a PropertyGrid in the form,and I write the form's
MouseMove
Event this way:

private void Form1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
......
propertyGrid1.Refresh();
......

}
If I move mouse into the form and don't move it. Form1_MouseMove is called
repeatly. Anybody know the reason?


Thx,
wyghf
 
S

Stoitcho Goutsev \(100\) [C# MVP]

wyghf,

I couldn't find the reason, but I found that the same happens if you hide
and show a control in the MouseMove event handler for example. I tired
couple ideas to overcome this, but the only one that worked was to check
whether the mouse position was actually changed when MouseMove comes. If it
wasn't then don't refresh the property gird

int oldX = -1, oldY = -1;

protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);



if(oldX != e.X && oldY != e.Y)
{
propertyGrid1.Refresh();
oldX = e.X;
oldY = e.Y;
}
}

HTH
Stoitcho Goutsev (100) [C# MVP]
 
G

Guest

Thanks for your reply.In fact I did as you did.But I don't know why.

Stoitcho Goutsev (100) said:
wyghf,

I couldn't find the reason, but I found that the same happens if you hide
and show a control in the MouseMove event handler for example. I tired
couple ideas to overcome this, but the only one that worked was to check
whether the mouse position was actually changed when MouseMove comes. If it
wasn't then don't refresh the property gird

int oldX = -1, oldY = -1;

protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);



if(oldX != e.X && oldY != e.Y)
{
propertyGrid1.Refresh();
oldX = e.X;
oldY = e.Y;
}
}

HTH
Stoitcho Goutsev (100) [C# MVP]

wyghf said:
I write a Vector Draw program.In my custom control,I override
OnMouseMove(...) in which I call PropertyGrid 's Refresh().Once
OnMouseMove
invoke,even if I don't
move mouse.It'll generate WM_MouseMove continously(using spy to monitor
it).

for example,there is a PropertyGrid in the form,and I write the form's
MouseMove
Event this way:

private void Form1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
......
propertyGrid1.Refresh();
......

}
If I move mouse into the form and don't move it. Form1_MouseMove is called
repeatly. Anybody know the reason?


Thx,
wyghf
 

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