以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求教狐爸:窗口中的button(按钮)移动问题?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=33486)

--  作者:chenjiu6202
--  发布时间:2013/5/19 11:14:00
--  求教狐爸:窗口中的button(按钮)移动问题?

Public XX,YY As Single

Public Sub Panel_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
   If e.Button = Windows.Forms.MouseButtons.Left Then
      XX = e.X
      YY = e.Y
    End If
End Sub

 

Public Sub Panel_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
    If e.Button = Windows.Forms.MouseButtons.Left Then sender.Parent.Location = New Point(sender.Parent.Location.X - XX + e.X, sender.Parent.Location.Y - YY + e.Y)
End Sub

 

\'窗口AfterLoad事件代码--------------------------------------------------------------------------------------------------------------------

AddHandler e.Form.Panel.MouseDown,AddressOf Panel_MouseDown
AddHandler e.Form.Panel.MouseMove,AddressOf Panel_MouseMove

 

这是狐爸去年发的帖子,窗口移动正常,如果是窗口里的button(按钮)移动,代码该怎么改啊,苦想了好几天没有结果啊,很想得到您的回复,期待!!!


--  作者:sloyy
--  发布时间:2013/5/19 18:27:00
--  
e.Form.Controls("Button1").Left=100
e.Form.Controls("Button1").Top =100

--  作者:don
--  发布时间:2013/5/19 18:30:00
--  
樓主大概想用滑鼠拖動吧
--  作者:chenjiu6202
--  发布时间:2013/5/19 20:20:00
--  
对啊,就是鼠标拖动啊
--  作者:jianjingmaoyi
--  发布时间:2013/5/19 20:41:00
--  
是不是这样?

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:移动控件.table



--  作者:chenjiu6202
--  发布时间:2013/5/19 22:38:00
--  

对啊,像你button4那样


--  作者:blackzhu
--  发布时间:2013/5/20 7:22:00
--  
      里面有4 5  个控件呢 不单单 只有一个控件 你仔细看看  除了4号控件 其他控件 移到什么地方 ,打开的时候就在什么地方.除了4号控件 不能保存位置
--  作者:chenjiu6202
--  发布时间:2013/5/20 8:07:00
--  

哈哈,是啊,如果是全局代码该怎么写啊