使用这个事件标签就消失了,我怎么做这个?
private void label4_MouseMove(object sender, MouseEventArgs e)
{
label4.Location = new Point(Cursor.Position.X, Cursor.Position.Y);
}
Run Code Online (Sandbox Code Playgroud)
小智 5
handle these three event ...
Control actcontrol;
Point preloc;
void label1_Mousedown(object sender, MouseEventArgs e)
{
actcontrol = sender as Control;
preloc = e.Location;
Cursor = Cursors.Default;
}
void label1_MouseMove(object sender, MouseEventArgs e)
{
if (actcontrol == null || actcontrol != sender)
return;
var location = actcontrol.Location;
location.Offset(e.Location.X - preloc.X, e.Location.Y - preloc.Y);
actcontrol.Location = location;
}
void label1_MouseUp(object sender, MouseEventArgs e)
{
actcontrol = null;
Cursor = Cursors.Default;
}
Run Code Online (Sandbox Code Playgroud)