how to refresh a user control in C#
Posted on 2013-01-11
hi - I'm using VS2010 and C#.
I have a user control on a windows form that i want to change its location. I can manage the logic to do that with the logic below. But as i drag it across the screen, it repaints at very noticable intervals, creating a "shadow" effect as it moves. i assume that it's repainting without "erasing" and every incremental move causes the new image to overlay before the old one is cancelled. how would i avoid the effect?
private void DisplayScriptVarConstCtl_MouseDown(object sender, MouseEventArgs e)
deltaX = this.Location.X - e.X;
deltaY = this.Location.Y - e.Y;
mouseIn = true;
private void DisplayScriptVarConstCtl_MouseMove(object sender, MouseEventArgs e)
this.Location = new Point(deltaX + e.X, deltaY + e.Y);
private void DisplayScriptVarConstCtl_MouseUp(object sender, MouseEventArgs e)
mouseIn = false;