数组中的 TabControl

TabControl in an array

我想将我的 TabControl 放在一个数组中

    For i As Int32 = 1 To 10
        Dim tabController = Me.Controls.Find("TabControl" & i, True)
        If tabController.Length > 0 Then
            tabController(0).Appearance = TabAppearance.Buttons
            tabController(0).SizeMode = TabSizeMode.Fixed
            tabController(0).ItemSize = New Drawing.Size(0, 1)
        End If
    Next

但是上面的代码似乎不起作用。我希望它是这样的

    TabControl1.Appearance = TabAppearance.Buttons
    TabControl1.SizeMode = TabSizeMode.Fixed
    TabControl1.ItemSize = New Drawing.Size(0, 1)

虽然我设法用按钮做到了

    For i As Int32 = 1 To 10
        Dim btns = Me.Controls.Find("btn" & i, True)
        If btns.Length > 0 Then
            btns(0).Text = "empty"
            btns(0).Visible = False
            AddHandler btns(0).Click, AddressOf Me.changeContent
        End If
    Next

提前致谢。

试试这个:

    For i = 1 To 10
        Dim tc As TabControl = Controls.Find("TabControl" & i, True).FirstOrDefault
        If Not tc Is Nothing Then
            tc.Appearance = TabAppearance.Buttons
            tc.SizeMode = TabSizeMode.Fixed
            tc.ItemSize = New Size(0, 1)
        End If
    Next