/// <summary> /// 在控件上移动鼠标时 /// </summary> void CustomControl_MouseMove(object sender, MouseEventArgs e) { if (IsMouse) { Point move = P_bgimg.PointToClient(Control.MousePosition); move.Offset(MovePoint); //偏移控件的相对位置 ((sender) as Control).Location = move; ((sender) as Control).Cursor = System.Windows.Forms.Cursors.SizeAll; //设置鼠标手形为移动 } }
/// <summary> /// 添加控件 /// </summary> private void Tool_controladd_Click(object sender, EventArgs e) { AddControl(P_bgimg.PointToClient(Control.MousePosition)); }