拖放TableLayoutPanel

时间:2016-06-08 07:11:48

标签: vb.net

有人可以帮我实现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

0 个答案:

没有答案