none
Problemas con AllowDrop RRS feed

  • Pregunta

  • Como puedo solucionar el siguiente problema...

    Tengo varios FlowLayowtPanel y necesito mover los Buttons que contienen, pero dentro de los FlowLayowtPanel donde están.

    Protected Overrides Sub OnGiveFeedback(ByVal gfbea As GiveFeedbackEventArgs) gfbea.UseDefaultCursors = False MyBase.OnGiveFeedback(gfbea) End Sub Private Sub btn1_DragOver(ByVal sender As Object, ByVal e As DragEventArgs) Handles b1.DragOver, b2.DragOver, b3.DragOver, b4.DragOver, b5.DragOver MyBase.OnDragOver(e) If Not e.Data.GetData(GetType(Button)) Is Nothing Then Dim flp As FlowLayoutPanel = TryCast(TryCast(sender, Button).Parent, FlowLayoutPanel) Dim myIndex As Integer = FlowLayoutPanel1.Controls.GetChildIndex(TryCast(sender, Button)) Dim btns As Button = DirectCast(e.Data.GetData(GetType(Button)), Button) FlowLayoutPanel1.Controls.SetChildIndex(btns, myIndex) btns.BackColor = Color.Gold End If End Sub Private Sub btn1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles b1.MouseDown, b2.MouseDown, b3.MouseDown, b4.MouseDown, b5.MouseDown MyBase.OnMouseDown(e) DoDragDrop(CType(sender, Button), DragDropEffects.Move) Dim btns As Button = CType(sender, Button) btns.BackColor = Color.Gainsboro End Sub Private Sub btn2_DragOver(ByVal sender As Object, ByVal e As DragEventArgs) Handles b6.DragOver, b7.DragOver, b8.DragOver, b9.DragOver, b10.DragOver MyBase.OnDragOver(e) If Not e.Data.GetData(GetType(Button)) Is Nothing Then Dim flp As FlowLayoutPanel = TryCast(TryCast(sender, Button).Parent, FlowLayoutPanel) Dim myIndex As Integer = FlowLayoutPanel2.Controls.GetChildIndex(TryCast(sender, Button)) Dim btns As Button = DirectCast(e.Data.GetData(GetType(Button)), Button) FlowLayoutPanel2.Controls.SetChildIndex(btns, myIndex) btns.BackColor = Color.Gold End If End Sub Private Sub btn2_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles b6.MouseDown, b7.MouseDown, b8.MouseDown, b9.MouseDown, b10.MouseDown MyBase.OnMouseDown(e) DoDragDrop(CType(sender, Button), DragDropEffects.Move) Dim btns As Button = CType(sender, Button) btns.BackColor = Color.Gainsboro End Sub

    ... ...

    En la implementacion sobreviene el error cuando muevo un Button y, sin querer, muevo el cursor al FlowLayoutPanel2.

    Si pudiese conseguir el mismo sistema sin tantos flowlayowtpanel, (8 en total), sería mejor pero no se cómo hacerlo.

    Gracias.


    • Editado RafaelFM miércoles, 17 de junio de 2015 20:50
    miércoles, 17 de junio de 2015 20:47