方案3 :
[c-sharp]view plaincopyprint?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestShow
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Point downPoint;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
downPoint = new Point(e.X, e.Y);
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Location = new Point(this.Location.X + e.X - downPoint.X,
this.Location.Y + e.Y - downPoint.Y);
}
}
}
[c-sharp]view plaincopyprint?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestShow
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Point downPoint;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
downPoint = new Point(e.X, e.Y);
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Location = new Point(this.Location.X + e.X - downPoint.X,
this.Location.Y + e.Y - downPoint.Y);
}
}
}