会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
星期六
首页
管理
.net 实现移动控件位置
public
partial
class
Form2 : Form
{
public
Form2()
{
InitializeComponent();
}
private
Point mouse_offset;
private
void
Form2_Load(
object
sender, EventArgs e)
{
}
private
void
button1_MouseDown(
object
sender, MouseEventArgs e)
{
mouse_offset
=
new
Point(
-
e.X,
-
e.Y);
//
}
private
void
button1_MouseMove(
object
sender, MouseEventArgs e)
{
((Control)sender).Cursor
=
Cursors.Arrow;
//
设置拖动时鼠标箭头
if
(e.Button
==
MouseButtons.Left)
{
Point mousePos
=
Control.MousePosition;
mousePos.Offset(mouse_offset.X, mouse_offset.Y);
//
设置偏移
((Control)sender).Location
=
((Control)sender).Parent.PointToClient(mousePos);
}
}
}
posted on
2008-04-25 11:48
星期六
阅读(
489
) 评论(
0
)
编辑
收藏
举报
刷新页面
返回顶部