Visual Basic 2008 PictureBox Drag & Drop

함흥처사 2014.06.05 07:49:34 *: Public Class Form1
Dim picstr() As String
Dim str As String
Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Dim picstr() As String
Dim str As String
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
picstr = e.Data.GetData(DataFormats.Bitmap)
str = picstr(0)
PictureBox1.ImageLocation = str
End If
End Sub

Private Sub PictureBox1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
e.Effect = e.AllowedEffect
End Sub



Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
PictureBox1.AllowDrop = True
End Sub
End Class




2차 코드 Public Class Form1
Public Class Form1
Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Dim picstr() As String
Dim str As String
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
picstr = e.Data.GetData(DataFormats.FileDrop)
str = picstr(0)
PictureBox1.ImageLocation = str
End If
End Sub

Private Sub PictureBox1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
e.Effect = e.AllowedEffect
End Sub



Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
PictureBox1.AllowDrop = True
End Sub
End Class