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

推荐订阅源

J
Java Code Geeks
量子位
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
A
About on SuperTechFans
腾讯CDC
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
Last Week in AI
Last Week in AI
H
Help Net Security
WordPress大学
WordPress大学
博客园 - 司徒正美
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tailwind CSS Blog
博客园 - 【当耐特】
S
SegmentFault 最新的问题
美团技术团队
M
MIT News - Artificial intelligence
L
LangChain Blog
博客园 - 聂微东

博客园 - 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);
  }
}