我为 TableLayoutPanel 动态生成控件。我在每一行都有一个删除按钮。当我单击它时,必须删除该行。
Dim removeBtn As New Button
AddHandler removeBtn.Click, AddressOf DeleteRow
tlp.Controls.Add(removeBtn, 5, rowCount)
我没有显示添加与上面类似的文本框的代码。我可以得到点击按钮的行号。使用它,如何从该行中删除所有控件。
Private Sub DeleteRow(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim currentRow As Integer = CType(CType(sender, Button).Parent, TableLayoutPanel).GetRow(CType(sender, Button))
'Using this currentRow, how to delete this Row
End Sub