TablePanelLayout最后一行似乎每次刷新都会增长吗?

问题描述 投票:0回答:1

每次我运行这段代码来向TableLayoutPanel添加控件时,最后一行似乎都在不断增长,我无法理解为什么。

InfoWindow.RowStyles.Clear()
InfoWindow.Controls.Clear()
InfoWindow.RowCount = 0


        For i As Integer = 0 To TextLines.Count - 8
            InfoWindow.RowCount += 1
            InfoWindow.RowStyles.Add(New RowStyle(SizeType.AutoSize))
            label = New Label With {.AutoSize = True, .Text = TextLines(i).Substring(0, TextLines(i).IndexOf("|")).Trim}
            InfoWindow.Controls.Add(label, 0, InfoWindow.RowCount - 1)

            label = New Label With {.AutoSize = True, .Text = TextLines(i).Substring(TextLines(i).IndexOf("|") + 1).Trim}
            InfoWindow.Controls.Add(label, 1, InfoWindow.RowCount - 1)
        Next

我第一次运行此代码,它看起来很好。如果我再次运行代码,最后一行会越来越大。在我运行代码几次后它看起来像这样......

enter image description here

我的代码在哪里使最后一行更大?我很难过。

我确保通过将行设置为0来清除行,我也清除了行样式和控件,但为什么最后一行每次变得越来越大?

vb.net
1个回答
0
投票

我想到了。这是因为TableLayoutPanel停靠栏设置为FILL。将其设置为无,再次为正常高度

© www.soinside.com 2019 - 2024. All rights reserved.