以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]如何实现鼠标拖拽功能  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=75045)

--  作者:黄训良
--  发布时间:2015/9/25 11:05:00
--  [求助]如何实现鼠标拖拽功能

如何实现鼠标拖拽功能,通过鼠标吧文件夹(完整路径)拖拽到窗口中的文本框里面?相当于【选择文件夹】按钮的功能,例子如下:

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:鼠标拖拽.foxdb


图片点击可在新窗口打开查看此主题相关图片如下:鼠标拖拽.png
图片点击可在新窗口打开查看

--  作者:逛逛
--  发布时间:2015/9/25 11:32:00
--  

 

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:鼠标拖拽.foxdb

 

 

全局代码

Public Sub TextBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)

        Dim path As String = CType(e.Data.GetData(Windows.Forms.DataFormats.FileDrop), System.Array).GetValue(0).ToString()
        sender.Text = path
        sender.Cursor = System.Windows.Forms.Cursors.IBeam
    End Sub

    Public Sub TextBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
        If (e.Data.GetDataPresent(Windows.Forms.DataFormats.FileDrop)) Then
            e.Effect = Windows.Forms.DragDropEffects.Link
            sender.Cursor = System.Windows.Forms.Cursors.Arrow 
        Else
            e.Effect = Windows.Forms.DragDropEffects.None
        End If
    End Sub

 

 

窗口AfterLoad代码

 

Dim t As WinForm.TextBox = e.Form.Controls("TextBox1")
t.BaseControl.AllowDrop = True

AddHandler t.BaseControl.DragDrop, AddressOf TextBox_DragDrop
AddHandler t.BaseControl.DragEnter, AddressOf TextBox_DragEnter

 

 

 

 

 

 

 

 

[此贴子已经被作者于2015/10/3 22:00:57编辑过]

--  作者:HappyFt
--  发布时间:2015/9/25 11:52:00
--  
学习
--  作者:大红袍
--  发布时间:2015/9/25 11:53:00
--  

mark


--  作者:pcxjxjhkw
--  发布时间:2015/9/25 13:11:00
--  
学习
--  作者:pcxjxjhkw
--  发布时间:2015/9/25 13:12:00
--  
老师,贴出代码吧!
--  作者:逛逛
--  发布时间:2015/9/25 13:23:00
--  
贴了
--  作者:Hyphen
--  发布时间:2015/9/25 13:29:00
--  
看看
--  作者:Exon_Liang
--  发布时间:2015/9/25 13:46:00
--  
study
--  作者:ztmdnzc
--  发布时间:2015/10/2 14:18:00
--  
学习