简体   繁体   English

不会将TabPage添加到TabControl

[英]won't add TabPage to TabControl

I'm trying to add a tabPage to an existing TabControl named TabControl4 I went all over it with the Debugger and everything is fine, but it won't show the TabPage in the TabControl. 我试图将tabPage添加到名为TabControl4的现有TabControl中,我使用调试器进行了遍历,一切都很好,但它不会在TabControl中显示TabPage。 That's the code, Notice all the information being added to the TabPage is retrieved from a database so don't pay any attention to it, plus the software is in Hebrew so just ignore the Hebrew Strings. 这就是代码,请注意,所有添加到TabPage的信息都是从数据库中检索出来的,因此不必理会它,而且该软件在希伯来语中,因此只需忽略希伯来字符串即可。

Table = DataBase.OpenRecordset("AthInj")
    Table.Index = "PrimaryKey"
    Table.Seek("=", AthId)
    Dim day1() As String = Table.Fields("injDay1").Value.ToString.Split("^")
    Dim month1() As String = Table.Fields("injMonth1").Value.ToString.Split("^")
    Dim year1() As String = Table.Fields("injYear1").Value.ToString.Split("^")
    Dim day2() As String = Table.Fields("injDay2").Value.ToString.Split("^")
    Dim month2() As String = Table.Fields("injMonth2").Value.ToString.Split("^")
    Dim year2() As String = Table.Fields("injYear2").Value.ToString.Split("^")
    Dim injs() As String = Table.Fields("inj").Value.ToString.Split("$")
    Dim treats() As String = Table.Fields("treat").Value.ToString.Split("$")
    Dim rehabs() As String = Table.Fields("rehab").Value.ToString.Split("$")
    For i As Integer = 0 To injs.Length - 2
        Dim tp As New TabPage
        tp.Text = "פציעה " & (i + 1)
        tp.Name = "inj" & i
        Dim bday1 As New ComboBox
        Dim bmonth1 As New ComboBox
        Dim byear1 As New ComboBox
        Dim bday2 As New ComboBox
        Dim bmonth2 As New ComboBox
        Dim byear2 As New ComboBox
        Dim da As Label
        Dim label1 As Label
        Dim label3 As Label
        Dim label4 As Label
        Dim multiText As New TextBox
        Dim ill As New TextBox
        Dim date2 As Label
        Dim rehabText As New TextBox
        da = setLabel("מתאריך:", "injda" & i, 17, 560)
        label1 = setLabel("הפציעה/מחלה:", "inj" & i, 133, 490)
        date2 = setLabel("עד לתאריך:", "date2" & i, 67, 560)
        label3 = setLabel("דרכי הטיפול:", "injtreat" & i, 187, 473)
        label4 = setLabel("דרכי השיקום:", "injrehab" & i, 326, 470)
        copyCombo(bday2, bday, i, 60, bday.Width, 71)
        copyCombo(bmonth2, bmonth, i, 230, bmonth.Width, 71)
        copyCombo(byear2, byear, i, 396, byear.Width, 71)
        bday2.Name = "bday2" & i
        bmonth2.Name = "bmonth2" & i
        byear2.Name = "byear2" & i
        byear2.SelectedIndex = byear2.FindStringExact(year2(i))
        bmonth2.SelectedIndex = month2(i)
        bday2.SelectedIndex = day2(i)
        copyCombo(bday1, bday, i, 60, bday.Width, da.Top + 4)
        copyCombo(bmonth1, bmonth, i, 230, bmonth.Width, da.Top + 4)
        copyCombo(byear1, byear, i, 396, byear.Width, da.Top + 4)
        byear1.SelectedIndex = byear1.FindStringExact(year1(i))
        bmonth1.SelectedIndex = month1(i)
        bday1.SelectedIndex = day1(i)
        setTextBox(ill, 138, 80, "ill" & i, False, ScrollBars.None, 400)
        ill.Text = injs(i)
        setTextBox(multiText, 191, 32, "treatText" & i, True, ScrollBars.Vertical, 399)
        setTextBox(rehabText, 330, 32, "rehabText" & i, True, ScrollBars.Vertical, 399)
        multilineToBox(treats(i), multiText)
        multilineToBox(rehabs(i), rehabText)
        With tp.Controls
            .Add(rehabText)
            .Add(ill)
            .Add(date2)
            .Add(bday2)
            .Add(bmonth2)
            .Add(byear2)
            .Add(da)
            .Add(label1)
            .Add(label3)
            .Add(label4)
            .Add(bday1)
            .Add(bmonth1)
            .Add(byear1)
            .Add(multiText)
        End With
        tp.AutoScroll = True
        tp.BackColor = Color.White
        tp.RightToLeft = Windows.Forms.RightToLeft.Yes
        TabControl4.Controls.Add(tp)
    Next

I just knocked up a little test app with a blank form and then added a TabControl and named it tabcontrol1. 我只是用空白表格打开了一个小测试应用程序,然后添加了一个TabControl并将其命名为tabcontrol1。

Then in the form load event added the following 然后在表单加载事件中添加以下内容

Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load

    Dim textbox1 As New TextBox With {.Text = "Textbox 1"}
    Dim tabPage1 As New TabPage With {.Text = "TabPage 1"}

    Dim textbox2 As New TextBox With {.Text = "Textbox 2"}
    Dim tabPage2 As New TabPage With {.Text = "TabPage 2"}


    tabPage1.Controls.Add(textbox1)
    tabPage2.Controls.Add(textbox2)

    TabControl1.TabPages.Add(tabPage1)
    TabControl1.TabPages.Add(tabPage2)

End Sub

And everything worked fine. 而且一切正常。 I think the only bit you have wrong in your code is where you have TabControl4.Controls.Add(tp) instead of TabControl4. 我认为您代码中唯一出错的地方是您拥有TabControl4.Controls.Add(tp)而不是TabControl4。 TabPages .Add(tp) TabPages .Add(tp)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何动态将标签页添加到标签控件并将 label 添加到标签页 - How can I add tabpage to tabcontrol dynamically and add label to tabpage 具有当前标签页三角形的TabControl - TabControl with current tabpage triangle 修复选项卡中的Tabcontrol选项卡位置 - Fix Tabcontrol Tabpage location in tabs VB.net | 我怎样才能把一个访问数据库记录变成一个tabcontrol添加tab页? - VB.net | how can i turn an access db record in to a tabcontrol add tabpage? 如何在TabControl上设置新的TabPage页面的属性? - How to set properties of new TabPage pages at TabControl? VB.net禁用TabControl的TabPage - VB.net disable a TabPage of a TabControl 我在运行时使用Tabcontrol创建的所有选项卡页即使在数据库中也无法显示第三个按钮 - All my tabpage create in runtime using Tabcontrol can't show 3rd button even i have it in my database 最后一个选项卡页旁边的空间包含在form1或tabcontrol1中 - The space next to the last tabpage is contained in form1 or tabcontrol1 尝试将UserControl添加到另一个TabPage内的TabPage中,获取NullReferenceException - Trying to add UserControl to a TabPage inside of another TabPage get NullReferenceException 动态将tabpanel添加到tabcontrol - Dynamically add tabpanel to tabcontrol
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM