跪求C#图形移动程序 直接更改Picture的Location即可 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你个参考:以下的代码画出了一个矩形,可以使用鼠标来拖动这个矩形.public partial class MoveRect : Form{ private Rectangle m_Rect; private Point m_LastMSPoint; public MoveRect() { InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); m_Rect = new Rectangle(10, 10, 50, 30); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.FillRectangle(SystemBrushes.ControlDark, this.m_Rect); e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, this.m_Rect); } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); this.m_LastMSPoint = e.Location; } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.Button != MouseButtons.Left) { return; } this.m_Rect.Offset(e.Location.X - this.m_LastMSPoint.X, e.Location.Y - this.m_LastMSPoint.Y); //绘制新的图形 this.Invalidate(); this.m_LastMSPoint = e.Location; }} 关于SQL数据库应用 VS2005 是否 类的图像方式的编辑窗口 如何用C#实现打包一个文件夹. 用VS2005打包,如何让主程序在安装完成后自动启动 C# dataGridView 列隐藏不了 请教?怎么用C#查找ACCESS数据库中的一段时间的数据 split OA系统里刷新APPLICATION,数据库的问题! 100分,求救,怎么读出数据库中的相片,急~~~~~~~~~,在线等,解决问题马上给分 .NET好书推荐.... C#里怎么获取临时表 一个关于关于remoting远程对象的问题
以下的代码画出了一个矩形,可以使用鼠标来拖动这个矩形.
public partial class MoveRect : Form
{
private Rectangle m_Rect;
private Point m_LastMSPoint;
public MoveRect()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
m_Rect = new Rectangle(10, 10, 50, 30);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.FillRectangle(SystemBrushes.ControlDark, this.m_Rect);
e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, this.m_Rect);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
this.m_LastMSPoint = e.Location;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button != MouseButtons.Left)
{
return;
}
this.m_Rect.Offset(e.Location.X - this.m_LastMSPoint.X, e.Location.Y - this.m_LastMSPoint.Y);
//绘制新的图形
this.Invalidate();
this.m_LastMSPoint = e.Location;
}
}