DevTrain Startseite Advanced Developers Conference vom 14.-15. Februar 2011  
  
  
SUCHEN:  
ARTIKEL ONLINE: 525   

Kategorien
.NET
Datenbanken
Web
XML

Allgemein
Camp
Foren
Events
Persönliche Einstellungen
Registrieren
Prämien Shop
Kontakt
Impressum
Über DevTrain

Autoren



 

Forum: VB.NET | Thema: Re: ListBox - Drag & Drop | Von: Timo Ulrich ( 03.06.2005 10:45)

Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
Dim lb As ListBox = CType(sender, ListBox)
Dim pt As New Point(e.X, e.Y)
Dim index As Integer = lb.IndexFromPoint(pt)
If index >= 0 Then
lb.DoDragDrop(lb.Items(index).ToString(), DragDropEffects.Copy)
End If
End Sub
Private Sub Listbox2_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles ListBox2.DragDrop
If (e.Data.GetDataPresent(GetType(System.String))) Then
Dim item As Object = CType(e.Data.GetData(GetType(System.String)), System.Object)
If (e.Effect = DragDropEffects.Copy Or _
e.Effect = DragDropEffects.Move) Then
If (ListBox1.SelectedIndex.ToString() <> ListBox.NoMatches) Then
ListBox2.Items.Insert(ListBox1.SelectedIndex.ToString(), item)
Else
ListBox2.Items.Add(item)
End If
End If
End If
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragEnter
If e.Data.GetDataPresent("Text") Then
e.Effect = DragDropEffects.Copy
End If
End Sub

Vorher zwei Listboxen erstellen (Bezeichnung Listbox1 und Listbox2) und mit ein paar Elementen füllen.

He likes to topple those who have the farthest to fall.


Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!

 Betreff:
 Nachricht: Den Beitrag finden Sie nun unter: http://beta.devtrain.de/foren Die Benutzerdaten und Foreninhalte von beta.devtrain.de und www.devtrain.de sind die selben.
Sie können sich dort sogar per RSS über neue Inhalte informieren lassen.
Bei Problemen bitte direkt Mail an asp [AT] ppedv.de.

 Signatur:

  



Login
Username:


Passwort:






Passwort vergessen?

Building und Connecting Know-how

© Copyright 2003 ppedv AG