TextBox AppendText(ControlChars CrLfsr ReadToEnd() ToString)
fs Close()
sr Close()
End If
Return False
End Function
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (ponents Is Nothing) Then
ponents Dispose()
End If
End If
Application RemoveMessageFilter(Me)
DragAcceptFiles(TextBox Handle ToInt False)
MyBase Dispose(disposing)
End Sub
lishixinzhi/Article/program/net/201311/13043
VB.NET拖放文本文件到TextBox获得其路径 。Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TextBox1.AllowDrop = True
End Sub
Private Sub TextBoxDragEnter(sender As Object, e As DragEventArgs) Handles TextBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim files As String()
Try
files = CType(e.Data.GetData(DataFormats.FileDrop), String())
Me.TextBox1.Text = files(files.Length - 1)
Catch ex As Exception
MessageBox.Show(ex.Message)
Return
End Try
End If
End Sub
TextBox1.AllowDrop = True 是开启拖放支持vb.net拖放文件,可以在窗体设计器里面开启它vb.net拖放文件,也可以代码开启 。
vb.net textbox1选中的文本,拖放到textbox2?很久没有上这里了,今天看到了这个问题,尝试做了一个;
本例以源文本框TextBox1全部文字作为拖放文字为例,实现拖放
1、向一个窗体中添加两个文本框 , 分别名为TextBox1,TextBox2 。注意:把TextBox2控件的AllowDrop属性设置成True , 这点不要遗漏 。
2、完整的代码如下:
Public Class Form1
Private MouseIsDown As Boolean = False
Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
'设置一个标志以显示鼠标已按下 。
MouseIsDown = True
End Sub
Private Sub TextBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove
If MouseIsDown Then
'开始拖动(将TextBox1的文本内容作为拖放内容) 。
TextBox1.DoDragDrop(TextBox1.Text, DragDropEffects.Copy)
End If
MouseIsDown = False
End Sub
Private Sub TextBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter
'检查正在被拖放的数据的格式 。
If (e.Data.GetDataPresent(DataFormats.Text)) Then
'显示复制光标(表示是拖放行为) 。
e.Effect = DragDropEffects.Copy
Else
'显示不放置光标(表示不是拖放行为) 。
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub TextBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
'粘贴文本(将拖放内容作为TextBox2的文本内容) 。
TextBox2.Text = e.Data.GetData(DataFormats.Text)
End Sub
End Class
【vb.net拖放文件 vba拖拽文件】vb.net拖放文件的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vba拖拽文件、vb.net拖放文件的信息别忘了在本站进行查找喔 。
推荐阅读
- 抖音电脑看直播卡顿,抖音电脑直播卡顿是什么原因导致的
- 在HTML中可以套JS吗,html语言可以嵌入css吗
- 即时性战略游戏,即时战略游戏定义
- 关于vb.netxml节点的信息
- jquery实现div的拖动,html5拖动div
- js获取当前月日期,js获取当前日期yyyymmdd
- ios手机直播变声工具,苹果手机直播怎么变声
- php创建数据库和表 php怎么创建数据库表
- 包含postgresql设置登录用户的词条