有人可以帮我实现TableLayoutPanel中的拖放操作。对于拖放法线来说,它很容易,但这里不存在PictureBox控件。 我必须将TableLayoutPanle_main中的图像滑动到TableLayoutPanle_plateau中的PictureBox
这是我尝试过的:
Private Sub TableLayoutPanel_main_MouseMove(sender As Object, e As MouseEventArgs) Handles TableLayoutPanel_main.MouseMove
Dim rep As DragDropEffects
If e.Button = Windows.Forms.MouseButtons.Left Then
rep = sender.DoDragDrop(sender.Controls, DragDropEffects.Move)
End If
End Sub
Private Sub TableLayoutPanel_plateau_DragEnter(sender As Object, e As DragEventArgs) Handles TableLayoutPanel_plateau.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
e.Effect = DragDropEffects.Move
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub TableLayoutPanel_plateau_DragDrop(sender As Object, e As DragEventArgs) Handles TableLayoutPanel_plateau.DragDrop
If TypeOf sender.Controls Is PictureBox Then
Dim pb As PictureBox = CType(sender.Controls, PictureBox)
pb.Image = e.Data.GetData(DataFormats.Bitmap)
End If
End Sub