Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

really need help with drag and drop!!

Status
Not open for further replies.

smcmanus

Technical User
Aug 1, 2001
25
CA
Have a data grid and I want to select a row and drag(copy) it to a list box or another data grid.

Any help at all would be appreciated.

Thanks

Sara
 
Here is some code to get you started. It simply allows drag and drop between two list boxes. I don't have any code handy for the data grid or flex grid, but I'm sure it uses the same methods:

Code:
Private Sub Form_Load()
    List1.AddItem "one"
    List1.AddItem "two"
    List1.AddItem "three"
End Sub

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton And List1.ListIndex >= 0 Then
            Label1.Caption = List1.List(List1.ListIndex)
            Label1.Move List1.Left + X, List1.Top + Y, TextWidth(List1.List(List1.ListIndex)), TextHeight("A")
            Label1.Drag
    End If
End Sub

Private Sub List2_DragDrop(Source As Control, X As Single, Y As Single)
    If TypeName(Source) = "Label" Then
        List2.AddItem Source.Caption
        List1.RemoveItem (List1.ListIndex)
    End If
End Sub

Private Sub List2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton And List2.ListIndex >= 0 Then
            Label1.Caption = List2.List(List2.ListIndex)
            Label1.Move List2.Left + X, List2.Top + Y, TextWidth(List2.List(List2.ListIndex)), TextHeight("A")
            Label1.Drag
    End If
End Sub

Private Sub List1_DragDrop(Source As Control, X As Single, Y As Single)
    If TypeName(Source) = "Label" Then
        List1.AddItem Source.Caption
        List2.RemoveItem (List2.ListIndex)
    End If
End Sub


Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top