none
how to get tablelayoutpanelcell position in visual basic RRS feed

  • Question

  • I want to double click on an image in a tablelayout panel cell and, depending on its screen position, enlarge the picturebox (and image) it contains. Every example that I've seen on this is in C#. Please point me to some good Visual Basic (2010) samples..

    Thanks. Ed



    ejl

    Monday, July 1, 2019 5:24 AM

Answers

  • Hi,

    I made a demo,you can try it.

      Private Sub TableLayoutPanel1_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles TableLayoutPanel1.MouseDoubleClick
    
            Dim row As Integer = 0
            Dim verticalOffset As Integer = 0
    
            For Each h As Integer In TableLayoutPanel1.GetRowHeights()
                Dim column As Integer = 0
                Dim horizontalOffset As Integer = 0
    
                For Each w As Integer In TableLayoutPanel1.GetColumnWidths()
                    Dim rectangle As Rectangle = New Rectangle(horizontalOffset, verticalOffset, w, h)
    
                    If rectangle.Contains(e.Location) Then
                        MsgBox(String.Format("row {0}, column {1} was double clicked", row, column))
                        Return
                    End If
    
                    horizontalOffset += w
                    column += 1
                Next
                verticalOffset += h
                row += 1
            Next
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 2, 2019 2:34 AM