Hallo,
ich hab da ein Problem was das Drag and Drop bei Pictureboxen betrifft.
Ich hab 3 Pictureboxen, 2 davon haben ein Bild.
Wenn ich die Frucht in die gekennzeichnete Richtung verschieb verschwindet das Buch, was es aber eigentlich nicht sollte.
Hier noch Screenshot das es vlt verständlicher ist:
Uploaded with ImageShack.us
Code:
Mfg
x_str
ich hab da ein Problem was das Drag and Drop bei Pictureboxen betrifft.
Ich hab 3 Pictureboxen, 2 davon haben ein Bild.
Wenn ich die Frucht in die gekennzeichnete Richtung verschieb verschwindet das Buch, was es aber eigentlich nicht sollte.
Hier noch Screenshot das es vlt verständlicher ist:
Uploaded with ImageShack.us
Code:
VB.NET-Quellcode
- Private m_MouseIsDown As Boolean 'MouseDown Event
- Private Sub frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'Drag and Drop aktivieren
- PictureBox1.AllowDrop = True
- PictureBox2.AllowDrop = True
- PictureBox20.AllowDrop = True
- End Sub
- Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
- PictureBox1.Image = e.Data.GetData(DataFormats.Bitmap)
- If Not e.KeyState = 8 Then
- PictureBox2.Image = Nothing
- PictureBox20.Image = Nothing
- End If
- End Sub
- Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
- If e.Data.GetDataPresent(DataFormats.Bitmap) Then
- If e.KeyState = 9 Then
- e.Effect = DragDropEffects.Copy
- Else
- e.Effect = DragDropEffects.Move
- End If
- Else
- e.Effect = DragDropEffects.None
- End If
- End Sub
- Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As _
- System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
- If Not PictureBox1.Image Is Nothing Then
- m_MouseIsDown = True
- End If
- End Sub
- Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As _
- System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
- If m_MouseIsDown Then
- PictureBox1.DoDragDrop(PictureBox1.Image, DragDropEffects.Copy Or _
- DragDropEffects.Move)
- End If
- m_MouseIsDown = False
- End Sub
- Private Sub PictureBox2_DragEnter(ByVal sender As Object, ByVal e As _
- System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragEnter
- If e.Data.GetDataPresent(DataFormats.Bitmap) Then
- If e.KeyState = 9 Then
- e.Effect = DragDropEffects.Copy
- Else
- e.Effect = DragDropEffects.Move
- End If
- Else
- e.Effect = DragDropEffects.None
- End If
- End Sub
- Private Sub PictureBox2_DragDrop(ByVal sender As Object, ByVal e As _
- System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragDrop
- PictureBox2.Image = e.Data.GetData(DataFormats.Bitmap)
- If Not e.KeyState = 8 Then
- PictureBox1.Image = Nothing
- End If
- End Sub
- Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
- If Not PictureBox2.Image Is Nothing Then
- m_MouseIsDown = True
- End If
- End Sub
- Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
- If m_MouseIsDown Then
- PictureBox1.DoDragDrop(PictureBox2.Image, DragDropEffects.Copy Or _
- DragDropEffects.Move)
- End If
- m_MouseIsDown = False
- End Sub
- Private Sub PictureBox20_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox20.DragDrop
- PictureBox20.Image = e.Data.GetData(DataFormats.Bitmap)
- If Not e.KeyState = 8 Then
- PictureBox1.Image = Nothing
- End If
- End Sub
- Private Sub PictureBox20_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox20.DragEnter
- If e.Data.GetDataPresent(DataFormats.Bitmap) Then
- If e.KeyState = 9 Then
- e.Effect = DragDropEffects.Copy
- Else
- e.Effect = DragDropEffects.Move
- End If
- Else
- e.Effect = DragDropEffects.None
- End If
- End Sub
- Private Sub PictureBox20_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox20.MouseDown
- If Not PictureBox20.Image Is Nothing Then
- m_MouseIsDown = True
- End If
- End Sub
- Private Sub PictureBox20_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox20.MouseMove
- If m_MouseIsDown Then
- PictureBox1.DoDragDrop(PictureBox20.Image, DragDropEffects.Copy Or _
- DragDropEffects.Move)
- End If
- m_MouseIsDown = False
- End Sub
Mfg
x_str
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „x_Str“ ()