AccessTr.neT

Tam Versiyon: Dizeleri Bir Listbox'tan Diğerine Sürükleyip Bırakın
Şu anda arşiv modunu görüntülemektesiniz. Tam versiyonu görüntülemek için buraya tıklayınız.
Sayfalar: 1 2
Visualbasic de yazılmış bu örneği accessde yapabilir miyiz
Drag and drop strings from one ListBox to another in Visual Basic .NET

' Start a drag.
Private Sub lst_MouseDown(ByVal sender As Object, ByVal e _
    As System.Windows.Forms.MouseEventArgs) Handles _
    lstFruits.MouseDown, lstAnimals.MouseDown
    Dim lst As ListBox = DirectCast(sender, ListBox)

    If e.Button = Windows.Forms.MouseButtons.Right Then
        Dim index As Integer = lst.IndexFromPoint(e.X, e.Y)
        If index <> ListBox.NoMatches Then
            Dim item As String = lst.Items(index)
            Dim drop_effect As DragDropEffects = _
                lst.DoDragDrop( _
                    lst.Items(index), _
                    DragDropEffects.Move Or _
                        DragDropEffects.Copy)

            ' If it was moved, remove the item from this
            ' list.
            If drop_effect = DragDropEffects.Move Then
                ' See if the user dropped the item in this
                ' ListBox
                ' at a higher position.
                If lst.Items(index) = item Then
                    ' The item has not moved.
                    lst.Items.RemoveAt(index)
                Else
                    ' The item has moved.
                    lst.Items.RemoveAt(index + 1)
                End If
            End If
        End If
    End If
End Sub
If the drag moves over a ListBox, the DragOver event gives the control a chance to allow or prohibit the drag. The following code checks whether the drag can provide a string as data. If so, then it checks whether the Ctrl key is down and allows a move or copy effect.

' Display the appropriate cursor.
Private Sub lstFruits_DragOver(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.DragEventArgs) Handles _
    lstFruits.DragOver, lstAnimals.DragOver
    Const KEY_CTRL As Integer = 8

    If Not (e.Data.GetDataPresent(GetType(System.String))) _
        Then
        e.Effect = DragDropEffects.None
    ElseIf (e.KeyState And KEY_CTRL) And _
    (e.AllowedEffect And DragDropEffects.Copy) = _
        DragDropEffects.Copy Then
        ' Copy.
        e.Effect = DragDropEffects.Copy
    ElseIf (e.AllowedEffect And DragDropEffects.Move) = _
        DragDropEffects.Move Then
        ' Move.
        e.Effect = DragDropEffects.Move
    End If
End Sub
' Drop the entry in the list.
Private Sub lstFruits_DragDrop(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.DragEventArgs) Handles _
    lstFruits.DragDrop, lstAnimals.DragDrop
    If e.Data.GetDataPresent(GetType(System.String)) Then
        If (e.Effect = DragDropEffects.Copy) Or _
        (e.Effect = DragDropEffects.Move) Then
            Dim lst As ListBox = DirectCast(sender, ListBox)
            Dim item As Object = _
                CType(e.Data.GetData(GetType(System.String)), _
                System.Object)
            Dim pt As Point = lst.PointToClient(New _
                Point(e.X, e.Y))
            Dim index As Integer = lst.IndexFromPoint(pt.X, _
                pt.Y)
            If index = ListBox.NoMatches Then
                lst.Items.Add(item)
            Else
                lst.Items.Insert(index, item)
            End If
        End If
    End If
End Sub
Her konuyu lütfen kendi bölümüne acınız.
ben bunu Access de yapmak istiyorum yani uyarlamak mümkünmü
Sitedeki sürükle bırak örneklerini incelediniz mi?
Sayfalar: 1 2