Solved

VB.net moving a panel onto a table layout panel

Posted on 2014-02-02
4
463 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

17 Experts available now in Live!

Get 1:1 Help Now