Results 1 to 4 of 4

Thread: Drag IT

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Unhappy

    Would it be possible to drag one value from a (a)list box into another (b)list box?

    And if so if I dragged more than one value into the (b)list box would it add then next value or overwright the first value?

  2. #2
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Yes it is possible.
    I will reply again with code.
    -Excalibur

  3. #3
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Code:
    Private Sub Form_Load()
        With Lista
            .AddItem "1"
            .AddItem "2"
            .AddItem "3"
            .AddItem "4"
            .AddItem "5"
            .AddItem "6"
            .AddItem "7"
            .AddItem "8"
            .AddItem "9"
        End With
    End Sub
    
    Private Sub Lista_OLESetData(Data As DataObject, DataFormat As Integer)
        Data.SetData Lista.List(Lista.ListIndex)
    End Sub
    
    Private Sub Listb_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
        With Listb
            .AddItem Data.GetData(1)
        End With
    End Sub
    You have to set the OLEDragMode to 1-Automatic for lista and the dropmode to 1-manual for listb.
    -Excalibur

  4. #4
    Guest
    You could also do this:

    Code:
    'Code from Megatron
    
    Dim StartDrag As Boolean
    
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        StartDrag = True
        strTemp = List1.Text
    End Sub
    
    Private Sub List2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If StartDrag = True Then
            List2.AddItem List1.Text
            List1.RemoveItem List1.ListIndex
        End If
        StartDrag = False
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width