(07-12-2023, 21:46)playmepe escribió: quisiera ordenar los archivos de un listbox con arrastrar y soltar con el mouse (así como drag & drop) pero en el mismo listbox, ya que así es más facil en mover el archivo seleccionado en el index que uno desea.

Private vip_linux As New String[]
Private cuentaindices As Integer = 0
Private primero As Integer = -1
Private segundo As Integer = -1
Public Sub Form_Open()
  vip_linux = ["Linux Torvalds",
    "Richard Stallman",
    "Andrew Morton",
    "Eric S Raymond",
    "Andrew Tridgell",
    "Mark Shuttleworth",
    "Marc Ewing",
    "Miguel de Icaza",
    "Michael Widenius",
    "Rasmus Lerdof"]
  ListBox1.List = vip_linux
End
Public Sub ListBox1_Select()
  If cuentaindices < 2 And primero = -1 Then
    primero = ListBox1.Index
    Inc cuentaindices
  Else If cuentaindices = 1 And segundo = -1 Then
    segundo = ListBox1.Index
    Inc cuentaindices
    Swap ListBox1[primero].Text, ListBox1[segundo].Text
    primero = -1
    segundo = -1
    cuentaindices = 0
  Endif
End
		
	Public Sub Form_Open()
  With ListBox1
    .Drop = True
    .List = ["aaaa", "bbbb", "cccc", "dddd", "eeee"]
  End With
End
Public Sub ListBox1_MouseDrag()
  
  With ListBox1
    .Tag = .Index
' Coge y arrastra el texto localizando la línea que lo contiene:
    .Drag(ListBox1.Text, "text/html")
  End With
End 
Public Sub ListBox1_Drop()
  Dim n As Byte
' Localiza el número de índice de la línea donde se va a liberar el texto tomado de la otra línea:
  n = Fix(Drag.Y / (ListBox1.ScrollH / ListBox1.Count))
' Asigna el texto contenido en la línea de liberación a la línea de recogida:
   ListBox1[ListBox1.Tag].Text = ListBox1[n].Text
   
' Suelta el texto de la frase de recogida:
  ListBox1[n].Text = Drag.Data
 
EndPublic Sub Form_Open()
  ListBox1.List = ["aaaa", "bbbb", "cccc", "dddd", "eeee"]
End
Public Sub ListBox1_MouseUp()
 
  With ListBox1
    If Not IsNull(.Tag) Then 
'...Consul romano-gauditano, Shell, me dió la idea:
      Swap ListBox1[.Tag].Text, ListBox1[.Index].Text
      .Tag = Null
    Else
      .Tag = .Index
    Endif
  End With
 
EndPublic Sub Form_Open()
  With ListBox1
    .Drop = True
    .List = ["aaaa", "bbbb", "cccc", "dddd", "eeee"]
  End With
End
Public Sub ListBox1_MouseDrag()
  
  ListBox1.Drag(ListBox1.Text, "text/html")
End 
Public Sub ListBox1_Drop()
  Dim n, c As Byte
  Dim ss As String[]
  n = Fix(Drag.Y / (ListBox1.ScrollH / ListBox1.Count))
  ss = ListBox1.List
  ss.Add(Drag.Data, n)
  c = ListBox1.Index
  
  If ListBox1.Index > n Then c = ListBox1.Index + 1 
  ss.Remove(c, 1)
  ListBox1.List = ss
End(08-12-2023, 05:12)vuott escribió: n = Fix(Drag.Y / (ListBox1.ScrollH / ListBox1.Count))
(11-12-2023, 15:15)Shell escribió: en la lista internacional sobre que no funciona el evento Mouse_Down() en Listbox.