4
您好我写这将dragginging图片框在WinForm的代码,这是我的代码:Windows窗体:图片框手动拖动图片解决方案的操作?
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
pictureBox1.Top=(56 * ((pictureBox1.Top + (e.Y - firsty))/56) + 3); //this for the correction of location of picture box
isdragging[0] = false;
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
isdragging[0] = true;
firstx = e.X;
firsty = e.Y;
changeclickingstatus(pictureBox1);//this about my program
for (sbyte i = 0; i < (sbyte)20; i++)//this about my program
{
clickindex[i] = (sbyte)1;//this about my program
}
clickindex[0] = (sbyte)0;//this about my program
dragtop = (sbyte)(pictureBox1.Top/56);//this about my program
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (isdragging[0])
{
if (pictureBox1.Location.Y + (e.Y - firsty) < 0)
{
pictureBox1.Top = 0;//these are the limits of dragging
}
else if (pictureBox1.Location.Y + (e.Y - firsty) > 290)
{
pictureBox1.Top = 290;//these are the limits of dragging
}
else
{
pictureBox1.Top = pictureBox1.Top + (e.Y - firsty);
}
if (pictureBox1.Location.X + (e.X - firstx) < 6)
{
pictureBox1.Left = 6;//these are the limits of dragging
}
else if (pictureBox1.Location.X + (e.X - firstx) > 280)
{
pictureBox1.Left = 280;//these are the limits of dragging
}
else
{
pictureBox1.Left = pictureBox1.Left + (e.X - firstx);
}
}
}
和我有相同的代码PictureBox的2,我的问题是: 当我拖着我的第一张照片第二个它会覆盖它并且代码正常工作,但是当我将第二个图片框拖动到第一个图片框时,第二个图片框会在第一个图片框下拖动!有没有这方面的财产?
谢谢你的回答,我第一次看到老答案,然后我学到的z-index概念,后来我发现backtofront功能与Z指数信息,然后我回来说ı找到答案,并看到你刚刚回答:) 再次感谢:) –