VB.NET如何实现用户可拖动无边界窗口的功能?

2026-05-08 11:413阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计341个文字,预计阅读时间需要2分钟。

VB.NET如何实现用户可拖动无边界窗口的功能?

我有张没有边框的表格,希望用户能移动。找不到任何可以让我这样做的工具。是否可以将边框设置为None的窗口?引入一个布尔变量,如果当前拖动了表格,则保存状态以及保存。

我有一个没有边框的表单,我希望用户能够移动.我找不到任何可以让我这样做的东西.

是否可以移动边框设置为None的窗口?

引入一个布尔变量,如果当前拖动了表单,则保存状态,以及保存拖动起始点的变量.然后OnMove相应地移动表单.由于这已在其他地方得到解答,我只需将其复制并粘贴到此处即可.

Class Form1 Private IsFormBeingDragged As Boolean = False Private MouseDownX As Integer Private MouseDownY As Integer Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then IsFormBeingDragged = True MouseDownX = e.X MouseDownY = e.Y End If End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp If e.Button = MouseButtons.Left Then IsFormBeingDragged = False End If End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove If IsFormBeingDragged Then Dim temp As Point = New Point() temp.X = Me.Location.X + (e.X - MouseDownX) temp.Y = Me.Location.Y + (e.Y - MouseDownY) Me.Location = temp temp = Nothing End If End Sub End Class

从www.dreamincode.net/forums/topic/59643-moving-form-with-formborderstyle-none/被盗

VB.NET如何实现用户可拖动无边界窗口的功能?

本文共计341个文字,预计阅读时间需要2分钟。

VB.NET如何实现用户可拖动无边界窗口的功能?

我有张没有边框的表格,希望用户能移动。找不到任何可以让我这样做的工具。是否可以将边框设置为None的窗口?引入一个布尔变量,如果当前拖动了表格,则保存状态以及保存。

我有一个没有边框的表单,我希望用户能够移动.我找不到任何可以让我这样做的东西.

是否可以移动边框设置为None的窗口?

引入一个布尔变量,如果当前拖动了表单,则保存状态,以及保存拖动起始点的变量.然后OnMove相应地移动表单.由于这已在其他地方得到解答,我只需将其复制并粘贴到此处即可.

Class Form1 Private IsFormBeingDragged As Boolean = False Private MouseDownX As Integer Private MouseDownY As Integer Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then IsFormBeingDragged = True MouseDownX = e.X MouseDownY = e.Y End If End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp If e.Button = MouseButtons.Left Then IsFormBeingDragged = False End If End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove If IsFormBeingDragged Then Dim temp As Point = New Point() temp.X = Me.Location.X + (e.X - MouseDownX) temp.Y = Me.Location.Y + (e.Y - MouseDownY) Me.Location = temp temp = Nothing End If End Sub End Class

从www.dreamincode.net/forums/topic/59643-moving-form-with-formborderstyle-none/被盗

VB.NET如何实现用户可拖动无边界窗口的功能?