none
my drop box RRS feed

  • Question

  • I can drag it but don't know how to drag it out

    Private Sub tsb_exit_Click(sender As Object, e As EventArgs) Handles tsb_exit.Click Application.Exit() End Sub Private Sub fmain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Text = "John's Docs" Me.Icon = My.Resources.icon_blue Me.gbox_01.AllowDrop = True Me.tss_01.Text = Environment.UserName.ToString Me.tss_02.Text = Nothing Me.tss_03.Text = Nothing End Sub Private Sub gbox_01_DragDrop(sender As Object, e As DragEventArgs) Handles gbox_01.DragDrop Dim files() As String = e.Data.GetData(DataFormats.FileDrop) For Each path In files If System.IO.Directory.Exists(path) = True Then Me.PictureBox1.Image = My.Resources.folder_full Else PictureBox1.Image = Drawing.Icon.ExtractAssociatedIcon(path).ToBitmap() End If Next End Sub Private Sub gbox_01_DragEnter(sender As Object, e As DragEventArgs) Handles gbox_01.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy End If End Sub Private Sub gbox_01_DragLeave(sender As Object, e As EventArgs) Handles gbox_01.DragLeave Me.PictureBox1.Image = Nothing

    'Not working

    End Sub


    Saturday, June 15, 2019 3:51 PM

All replies

  • You need to start the drag process in a mousedown or similar event.

       Private Sub TextBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles TextBox1.MouseDown
            TextBox1.DoDragDrop(TextBox1, DragDropEffects.Copy)
        End Sub

    Saturday, June 15, 2019 4:44 PM
  • Hi thank you for answering my post

    I want to clear the Picture box

    Me.PictureBox1.Image = Nothing

    Saturday, June 15, 2019 4:49 PM
  • Hi,

    like this?

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.AllowDrop = True
            Me.gbox_01.AllowDrop = True
            Me.PictureBox1.Image = Image.FromFile("D:\image\day.jpg")
    
        End Sub
        Private Sub gbox_01_DragDrop(sender As Object, e As DragEventArgs) Handles gbox_01.DragDrop
    
            Me.gbox_01.Controls.Add(PictureBox1)
            PictureBox1.Location = New Point(gbox_01.PointToClient(Control.MousePosition).X, gbox_01.PointToClient(Control.MousePosition).Y)
            PictureBox1.Image = e.Data.GetData(DataFormats.Bitmap)
        End Sub
        Private Sub gbox_01_DragEnter(sender As Object, e As DragEventArgs) Handles gbox_01.DragEnter
    
            If e.Data.GetDataPresent(GetType(Bitmap)) Then
                e.Effect = DragDropEffects.Copy
            Else
                e.Effect = DragDropEffects.None
            End If
        End Sub
        Private Sub gbox_01_DragLeave(sender As Object, e As EventArgs) Handles gbox_01.DragLeave
            PictureBox1.Image = Nothing
    
        End Sub
    
        Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
            CType(sender, PictureBox).DoDragDrop(CType(sender, PictureBox).Image, DragDropEffects.All)
        End Sub
    
    
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 18, 2019 2:11 AM
    Moderator