惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
GbyAI
GbyAI
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 叶小钗
A
About on SuperTechFans
M
MIT News - Artificial intelligence
宝玉的分享
宝玉的分享
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Martin Fowler
Martin Fowler
Google DeepMind News
Google DeepMind News
博客园 - Franky
B
Blog RSS Feed
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - NanKe Sir's Blog

设置RDLC报表参数 - NanKe Sir's Blog 用SQL语句查询累计值 C#调用存储过程通用类3 TreeView查找 在 DataGridView 中实现类似 Ctrl + F 的查找功能 正则表达式使用 Collapsing margins CSS基础 打开 mdi 窗体的子窗体 从绑定了数据源的 ListBox 中删除多个选定项 计算24点代码javascript 对数据库表进行简单的增删改查操作的通用类 C#存储过程调用 SQL连接查询AND和WHERE的不同 我为什么憎恨Framework SQL选择所最近一条记录 Sql Server 日期格式转换 INSERT INTO SELECT FROM 的用法 无法将输入 xml 文件内容转换为数据集
Winform控件拖动
NanKe Sir's Blog · 2009-06-18 · via 博客园 - NanKe Sir's Blog

给要实现拖动的控件添加如下的 MouseDown 和 MouseMove 事件即可。

private Point startPoint;
private void MouseDown(object sender, MouseEventArgs e) {
  startPoint.X = e.X;
  startPoint.Y = e.Y;
}
private void MouseMove(object sender, MouseEventArgs e) {
  
if (e.Button == MouseButtons.Left) {
      Point mousePositon = Control.MousePosition;
      mousePositon.Offset(-startPoint.X, -startPoint.Y);
      Control ctrl = (Control)sender;
      ctrl.Location = ctrl.Parent.PointToClient(mousePositon);
  }
}