使用鼠标位置表获取单元格位置 [英] fetch cell position using mouse position tablelayoutpanel vb.net

查看:346
本文介绍了使用鼠标位置表获取单元格位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从tablelayoutpanel获取单元格位置,
我尝试了MouseMove事件,但无法正常运行

I want to fetch cell position from tablelayoutpanel,
I try MouseMove event but doesn''t work properly

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

推荐答案

您可能应该知道,当鼠标悬停在TableLayoutPanel内部的控件上时,不会触发TMP的MouseMove事件.那是因为鼠标不再位于TLP中,而是位于组成控件中.
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.


这篇关于使用鼠标位置表获取单元格位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆