Solved

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

Posted on 2014-02-02
2
1,147 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

21 Experts available now in Live!

Get 1:1 Help Now