用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - vb代码库

拖拽鼠标

2013-09-03 作者: JonMX举报

[vb]代码库

Public Class Form1
    Dim a, b As Integer
    Dim full As Integer = 10000
    Dim attack As Integer = 1000
  

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub


    Private Sub ButtonTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonTime.Click
        Label1.Text = "现在时间" + Now
        a = full
        b = full

    End Sub

 
    Private Sub Button1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
        '左键的话,标志位为true(表示拖拽开始)
        If (e.Button = Windows.Forms.MouseButtons.Left) Then
            Button1.DoDragDrop(Button1, DragDropEffects.Copy Or DragDropEffects.Move)   '形成拖拽效果,移动+拷贝的组合效果
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.AllowDrop = True
    End Sub

    Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
        If (e.Data.GetDataPresent(GetType(Button))) Then    '当Button被拖拽到WinForm上时候,鼠标效果出现
            e.Effect = DragDropEffects.Move
        End If
    End Sub

    Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop

        Button1.Location = Me.PointToClient(New Point(e.X, e.Y))
    End Sub
End Class


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...