
30/09/2004, 01:47
|
| | Fecha de Ingreso: septiembre-2004
Mensajes: 29
Antigüedad: 20 años, 5 meses Puntos: 0 | |
Hola Asturiano!
Te paso un ejemplo de uso del método DoDragDrop, en concreto se muestra una operación de arrastrar y colocar entre dos controles ListBox. A partir de aquí supongo te será fácil buscar tu solución.
Nota: te paso la clase en varios mensajes ya que es muy larga.
Parte_1:
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public NotInheritable Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents ListDragSource As System.Windows.Forms.ListBox
Friend WithEvents ListDragTarget As System.Windows.Forms.ListBox
Friend WithEvents UseCustomCursorsCheck As System.Windows.Forms.CheckBox
Friend WithEvents DropLocationLabel As System.Windows.Forms.Label
Private indexOfItemUnderMouseToDrag As Integer
Private indexOfItemUnderMouseToDrop As Integer
Private dragBoxFromMouseDown As Rectangle
Private screenOffset as Point
Private MyNoDropCursor As Cursor
Private MyNormalCursor As Cursor
<System.STAThread()> _
Public Shared Sub Main()
System.Windows.Forms.Application.Run(New Form1())
End Sub 'Main
Public Sub New()
MyBase.New()
Me.ListDragSource = New System.Windows.Forms.ListBox()
Me.ListDragTarget = New System.Windows.Forms.ListBox()
Me.UseCustomCursorsCheck = New System.Windows.Forms.CheckBox()
Me.DropLocationLabel = New System.Windows.Forms.Label()
Me.SuspendLayout()
' ListDragSource
Me.ListDragSource.Items.AddRange(New Object() {"one", "two", "three", "four", _
"five", "six", "seven", "eight", _
"nine", "ten"})
Me.ListDragSource.Location = New System.Drawing.Point(10, 17)
Me.ListDragSource.Size = New System.Drawing.Size(120, 225)
' ListDragTarget
Me.ListDragTarget.AllowDrop = True
Me.ListDragTarget.Location = New System.Drawing.Point(154, 17)
Me.ListDragTarget.Size = New System.Drawing.Size(120, 225)
' UseCustomCursorsCheck
Me.UseCustomCursorsCheck.Location = New System.Drawing.Point(10, 243)
Me.UseCustomCursorsCheck.Size = New System.Drawing.Size(137, 24)
Me.UseCustomCursorsCheck.Text = "Use Custom Cursors"
' DropLocationLabel
Me.DropLocationLabel.Location = New System.Drawing.Point(154, 245)
Me.DropLocationLabel.Size = New System.Drawing.Size(137, 24)
Me.DropLocationLabel.Text = "None"
' Form1
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 270)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListDragSource, _
Me.ListDragTarget, Me.UseCustomCursorsCheck, _
Me.DropLocationLabel})
Me.Text = "Drag and Drop Example"
Me.ResumeLayout(False)
End Sub |