none
如何实现FlowLayoutPanel内拖放Panel RRS feed

答案

  • Me.FlowLayoutPanel1.AllowDrop = True

    Private Sub Panel3_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel3.MouseDown

            Panel3.DoDragDrop(Panel3, DragDropEffects.Move)
        End Sub

    Private Sub FlowLayoutPanel1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles FlowLayoutPanel1.DragEnter
            If e.Data.GetDataPresent(GetType(Panel)) Then
                e.Effect = DragDropEffects.Move
            Else
                e.Effect = DragDropEffects.None
            End If

        End Sub

    Private Sub FlowLayoutPanel1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles FlowLayoutPanel1.DragDrop

            Dim mousePosition As Point = FlowLayoutPanel1.PointToClient(New Point(e.X, e.Y))
            Dim destination As Control = FlowLayoutPanel1.GetChildAtPoint(mousePosition)
            Dim indexDestination As Integer = FlowLayoutPanel1.Controls.IndexOf(destination)
            If (FlowLayoutPanel1.Controls.IndexOf(Panel3) < indexDestination) Then
                indexDestination = indexDestination - 1
            End If

            FlowLayoutPanel1.Controls.SetChildIndex(Panel3, indexDestination)
           
        End Sub


    http://feiyun0112.cnblogs.com/
    2009年5月25日 2:30
    版主

全部回复

  • Me.FlowLayoutPanel1.AllowDrop = True

    Private Sub Panel3_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel3.MouseDown

            Panel3.DoDragDrop(Panel3, DragDropEffects.Move)
        End Sub

    Private Sub FlowLayoutPanel1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles FlowLayoutPanel1.DragEnter
            If e.Data.GetDataPresent(GetType(Panel)) Then
                e.Effect = DragDropEffects.Move
            Else
                e.Effect = DragDropEffects.None
            End If

        End Sub

    Private Sub FlowLayoutPanel1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles FlowLayoutPanel1.DragDrop

            Dim mousePosition As Point = FlowLayoutPanel1.PointToClient(New Point(e.X, e.Y))
            Dim destination As Control = FlowLayoutPanel1.GetChildAtPoint(mousePosition)
            Dim indexDestination As Integer = FlowLayoutPanel1.Controls.IndexOf(destination)
            If (FlowLayoutPanel1.Controls.IndexOf(Panel3) < indexDestination) Then
                indexDestination = indexDestination - 1
            End If

            FlowLayoutPanel1.Controls.SetChildIndex(Panel3, indexDestination)
           
        End Sub


    http://feiyun0112.cnblogs.com/
    2009年5月25日 2:30
    版主
  • 谢了  我慢慢去完善下

    2009年5月25日 7:46