效果展示

需要三个鼠标的时间来配合
int x;
int y;
bool isMouthDown = false;
int width;
int height;
Graphics g;
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
x = e.X;
y = e.Y;
isMouthDown = true;
}
private void Form2_MouseMove(object sender, MouseEventArgs e)
{
if (isMouthDown)
{
width = Math.Abs(e.X - x);
height = Math.Abs(e.Y - y);
g = CreateGraphics();
g.Clear(BackColor);
g.FillRectangle(Brushes.CornflowerBlue,
x < MousePosition.X ? x : e.X,
y < MousePosition.Y ? y : e.Y,
width, height);
}
}
private void Form2_MouseUp(object sender, MouseEventArgs e)
{
width = Math.Abs(e.X - x);
height = Math.Abs(e.Y - y);
g = CreateGraphics();
g.Clear(BackColor);
g.FillRectangle(Brushes.CornflowerBlue,
x < MousePosition.X ? x : e.X,
y < MousePosition.Y ? y : e.Y,
width, height);
isMouthDown = false;
}