Click here to Skip to main content
15,920,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to fetch cell position from tablelayoutpanel,
I try MouseMove event but doesn't work properly

VB
Private Sub AaaGrid1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tlp.MouseMove
       Dim Row As Integer = 0
       Dim VSpace As Integer = 0
       For Each h As Integer In tlp.GetRowHeights()
           Dim Column As Integer = 0
           Dim HSpace As Integer = 0
           For Each w As Integer In tlp.GetColumnWidths()
               Dim Rect As New Rectangle(HSpace, VSpace, w, h)
               If (Rect.Contains(e.Location)) Then
                   Try
                       If Column > RowCollectionTagAry.Count And Row > ColCollectionTagAry.Count Then
                           Me.FindForm.Text = "col = " & Column - RowCollectionTagAry.Count & "  row = " & Row - ColCollectionTagAry.Count
                       End If
                   Catch ex As Exception
                   End Try
                   Return
               End If
               HSpace += w
               Column += 1
           Next
           VSpace += h
           Row += 1
       Next
   End Sub
Posted
Comments
ArtificerGM 18-Jul-12 6:52am    
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.pointtoscreen.aspx

Here is the direction you need to go. Happy coding!
Sandeep Mewara 18-Jul-12 14:36pm    
"MouseMove event but doesn't work properly" -> Elaborate.

1 solution

You should probably know that when the mouse is over a control that is inside the TableLayoutPanel, the MouseMove event for the TMP will NOT fire. That's because the mouse is no longer inside the TLP, but inside the constituent control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900