Solved

VB.net get cell row and column number in TableLayoutPanel after drag and drop

Posted on 2014-02-02
2
1,193 Views
Last Modified: 2014-02-03
How do I get cell row and column number in TableLayoutPanel after drag and drop
done using the following code:

   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 Comments
 
LVL 16

Accepted Solution

by:
SriVaddadi earned 500 total points
ID: 39829553
Use GetChildAtPoint(Point) and GetPositionFromControl methods to get the TableLayoutPanelCellPosition for the point (cursor position from DragEventArgs X and Y)
0
 

Author Closing Comment

by:murbro
ID: 39829561
Thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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