关于vb.net拖拽数据源的信息

VB.net 实现TreeView控件的拖拽事件

注意看看控件的属性,这个是可以靠修改属性来更改的,里面有接收拖曳进来的数据和拖曳出去的数据的属性,改成ture就可以拖曳了csdn中有拖曳的实例,就是以treeview控件为例子的,去找找,我上次见过,好像在控件那部分

海宁网站建设公司创新互联,海宁网站设计制作,有大型网站制作公司丰富经验。已为海宁成百上千家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的海宁做网站的公司定做!

VB.net怎么实现控件拖动的时候显示里面的内容?

在控件的MouseDown事件中,记录控件的当前位置和鼠标坐标,并设置一个标志变量表示进入拖动状态;在MouseMove事件中,判断如果当前是拖动状态,则根据鼠标的当前坐标和MouseDown时的坐标计算出移动量,更改控件位置;在MouseUp事件中清除标志变量。

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 如何实现拖拽

打一个AjaxControlToolkit补丁包

里面有很多控件

就有你想要的拖拽控件

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的ListBox怎样实现项目可以拖动

追问: 额,没有学过C# 回答: 一样的 Imports System.Drawing Imports System.Collections Imports System.ComponentModel Imports System.Windows.Forms Imports System.Data Namespace WindowsApplication2 Public Class Form1 Inherits System.Windows.Forms.Form Private listBox1 As System.Windows.Forms.ListBox Private indexofsource As Integer '拖动的起始索引 Private indexoftarget As Integer '拖动的结束索引 Private components As System.ComponentModel.Container = Nothing Public Sub New() InitializeComponent() End Sub Protected Overrides Sub Dispose(disposing As Boolean) If disposing Then If components IsNot Nothing Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private Sub InitializeComponent() Me.listBox1 = New System.Windows.Forms.ListBox() Me.SuspendLayout() ' ' listBox1 ' Me.listBox1.AllowDrop = True '这个属性一定要设置为true; Me.listBox1.ItemHeight = 12 Me.listBox1.Items.AddRange(New Object() {"1", "2", "3", "4", "5", "6", _ "7", "8", "9", "0"}) Me.listBox1.Location = New System.Drawing.Point(16, 8) Me.listBox1.Name = "listBox1" Me.listBox1.ScrollAlwaysVisible = True Me.listBox1.Size = New System.Drawing.Size(264, 136) Me.listBox1.TabIndex = 0 AddHandler Me.listBox1.MouseDown, New System.Windows.Forms.MouseEventHandler(AddressOf Me.listBox1_MouseDown) AddHandler Me.listBox1.DragOver, New System.Windows.Forms.DragEventHandler(AddressOf Me.listBox1_DragOver) AddHandler Me.listBox1.DragDrop, New System.Windows.Forms.DragEventHandler(AddressOf Me.listBox1_DragDrop) Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.listBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub STAThread _ Private Shared Sub Main() Application.Run(New Form1()) End Sub Private Sub listBox1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) indexofsource = DirectCast(sender, ListBox).IndexFromPoint(e.X, e.Y) If indexofsource ListBox.NoMatches Then DirectCast(sender, ListBox).DoDragDrop(DirectCast(sender, ListBox).Items(indexofsource).ToString(), DragDropEffects.All) End If End Sub Private Sub listBox1_DragOver(sender As Object, e As System.Windows.Forms.DragEventArgs) '拖动源和放置的目的地一定是一个ListBox If e.Data.GetDataPresent(GetType(System.String)) AndAlso DirectCast(sender, ListBox).Equals(listBox1) Then e.Effect = DragDropEffects.Move Else e.Effect = DragDropEffects.None End If End Sub Private Sub listBox1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Dim listbox__1 As ListBox = DirectCast(sender, ListBox) indexoftarget = listbox__1.IndexFromPoint(listbox__1.PointToClient(New Point(e.X, e.Y))) If indexoftarget ListBox.NoMatches Then Dim temp As String = listbox__1.Items(indexoftarget).ToString() listbox__1.Items(indexoftarget) = listbox__1.Items(indexofsource) listbox__1.Items(indexofsource) = temp listbox__1.SelectedIndex = indexoftarget End If End Sub End Class End Namespace


文章题目:关于vb.net拖拽数据源的信息
标题链接:http://myzitong.com/article/hhoepd.html