Solved

VB.net moving a panel onto a table layout panel

Posted on 2014-02-02
4
465 Views
Last Modified: 2014-02-03
Hi

I use the following code to move a panel with an image onto a table layout panel.
I want to update the code so that the original panel also stays in the original position


   Dim ptOriginal As Point = Point.Empty


    Private Sub BarChart_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles BarChart.MouseDown
        Try
            ptOriginal = New Point(e.X, e.Y)
            Me.TableLayoutPanel1.AllowDrop = True
            DirectCast(sender, Control).DoDragDrop(sender, DragDropEffects.All)
        Catch ex As Exception
            MsgBox("There was an error dragging " & ex.Message)
        End Try
    End Sub

   

    Private Sub TableLayoutPanel1_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles TableLayoutPanel1.DragEnter
        If e.Data.GetDataPresent(GetType(System.Windows.Forms.Panel)) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub

    Private Sub TableLayoutPanel1_DragOver(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles TableLayoutPanel1.DragOver
        DirectCast(e.Data.GetData(GetType(System.Windows.Forms.Panel)), Control).Location = Me.PointToClient(New Point(e.X - ptOriginal.X, e.Y - ptOriginal.Y))
        DirectCast(e.Data.GetData(GetType(System.Windows.Forms.Panel)), Control).BringToFront()
    End Sub

    Private Sub TableLayoutPanel1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles TableLayoutPanel1.DragDrop
        DirectCast(e.Data.GetData(GetType(System.Windows.Forms.Panel)), Panel).BringToFront()
    End Sub
0
Comment
Question by:murbro
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 39829567
So do you want to copy when an object dragged and dropped?
0
 

Author Comment

by:murbro
ID: 39829576
Yes
0
 
LVL 16

Accepted Solution

by:
SriVaddadi earned 500 total points
ID: 39829587
Use DragDropEffects.Copy in place of DragDropEffects.All and try
0
 

Author Closing Comment

by:murbro
ID: 39829591
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now