1
我想拖放绘制在窗体上的图形。这是我绘制矩形的代码。这工作正常。使用绘制矩形拖放功能C#.net - 形式
Rectangle rec = new Rectangle(0, 0, 0, 0);
public Form1()
{
InitializeComponent();
this.DoubleBuffered = true;
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Aquamarine, rec);
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
rec = new Rectangle(e.X, e.Y, 0, 0);
Invalidate();
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
rec.Width = e.X - rec.X;
rec.Height = e.Y - rec.Y;
Invalidate();
}
}
现在我想将该矩形拖放到不同的位置。
请帮助如何做到这一点
谢谢
YOHAN
不错的一个:)我不认为我们可以移动矩形,我们需要一些控制。 – Anuraj 2011-03-15 07:39:20