c#中 pictureBox控件里的image在picturebox中移动
就是picturebox控件里的image,在image中移动,而不是整个picturebox在form1窗体上移动...
就是picturebox控件里的image,在image中移动,而不是整个picturebox在form1窗体上移动
展开
2个回答
展开全部
private bool isMouseDown = false;
private Point mouseOffset; //记录鼠标指针的坐标
private void PicBox_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOffset.X = e.X;
mouseOffset.Y = e.Y;
isMouseDown = true;
}
}
private void PicBox_MouseMove(object sender, MouseEventArgs e)
{
if (isMouseDown)
{
int left = PicBox.Left + e.X - mouseOffset.X;
int top = PicBox.Top + e.Y - mouseOffset.Y;
PicBox.Location = new Point(left,top);
}
}
private void PicBox_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = false;
}
}
private Point mouseOffset; //记录鼠标指针的坐标
private void PicBox_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOffset.X = e.X;
mouseOffset.Y = e.Y;
isMouseDown = true;
}
}
private void PicBox_MouseMove(object sender, MouseEventArgs e)
{
if (isMouseDown)
{
int left = PicBox.Left + e.X - mouseOffset.X;
int top = PicBox.Top + e.Y - mouseOffset.Y;
PicBox.Location = new Point(left,top);
}
}
private void PicBox_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = false;
}
}
追问
…别捣乱,谢谢
追答
picturebox外面再加个picturebox 不就可以了吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public Form1()
{
InitializeComponent();
timer1.Enabled = true;
}
static int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Interval = 100;
i = i + 10;
Image newImage = Image.FromFile(@"D:\0133583.jpg");
Graphics g = pictureBox1.CreateGraphics();
g.DrawImage(newImage,i,10);
}
{
InitializeComponent();
timer1.Enabled = true;
}
static int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Interval = 100;
i = i + 10;
Image newImage = Image.FromFile(@"D:\0133583.jpg");
Graphics g = pictureBox1.CreateGraphics();
g.DrawImage(newImage,i,10);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询