C#怎么用button去控制图片的上下左右位移
2个回答
展开全部
bool flag = false; //定义变量,用来标识鼠标是否移动
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
flag = true; //将标识设置为true
}
private void Frm_Main_MouseMove(object sender, MouseEventArgs e)
{
if (flag) //如果鼠标在窗体中移动
pictureBox1.Location = new System.Drawing.Point(e.X, e.Y); //定义PictureBox控件的坐标位置
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
flag = true; //将标识设置为true
}
private void Frm_Main_MouseMove(object sender, MouseEventArgs e)
{
if (flag) //如果鼠标在窗体中移动
pictureBox1.Location = new System.Drawing.Point(e.X, e.Y); //定义PictureBox控件的坐标位置
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询