//以ä¸æ¯è®¾ç½®PictureBox移å¨ç代ç using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class FrmPiceboxTd : Form
{
public FrmPiceboxTd()
{
InitializeComponent();
foreach (Control c in this.Controls)
{
if (c is PictureBox)
{
c.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pic_MouseMove);
c.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pic_MouseDown);
}
}
}
private Point downPoint;//åå»pictureboxçåæ private void pic_MouseDown(object sender, MouseEventArgs e)
{
//设置åå»pictureboxçåæ
if (e.Button == MouseButtons.Left)
{
downPoint = e.Location;
}
} private void pic_MouseMove(object sender, MouseEventArgs e)
{
//å®ç°å¾çéé¼ æ æå¨
if (e.Button == MouseButtons.Left)
{
((Control)sender).Location = new Point(
((Control)sender).Location.X + e.X - downPoint.X,
((Control)sender).Location.Y + e.Y - downPoint.Y);
}
}
}
}
温馨提示:内容为网友见解,仅供参考