Results 1 to 9 of 9

Thread: TabControl...

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    TabControl...

    how do i put controls at run-time in tabs created at run-time in a tabcontrol?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    VB Code:
    1. Dim txt As New TextBox()
    2. TabControl1.Controls.Add(txt)
    3. txt.Visible=True
    4. txt.Location=New Point(0,0)

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

    Additional information: Cannot add 'TextBox' to TabControl. Only TabPages can be directly added to TabControls.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Opps that is my bad, you have to add it to the TabPage1.Controls collection not the tabcontrol itself, sorry. If there are no tabpages then you can add one to the tab control then add the controls to it.

    VB Code:
    1. Dim tp As New TabPage()
    2. TabControl1.Controls.Add(tp)
    3. Dim txt As New TextBox()
    4. tp.Controls.Add(txt)
    5. txt.Visible=True
    6. txt.Location=New Point(0,0)

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yea lol

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i have a question..imagine i want to create tabs at run-time and create in them textbox's at run-time..how do i do that?

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Originally posted by Edneeis
    VB Code:
    1. Dim tp As New TabPage()
    2. TabControl1.Controls.Add(tp)
    3. Dim txt As New TextBox()
    4. tp.Controls.Add(txt)
    5. txt.Visible=True
    6. txt.Location=New Point(0,0)
    That is exactly what that does. You'll probably want to change the location to something other than the very top left most corner though.

  8. #8

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yea lol i suck

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah tks did what i want :

    PHP Code:
            private void button2_Click(object senderSystem.EventArgs e)
            {
                
    TabPage tpTab = new TabPage(tabControl1.TabPages.Count.ToString());
                
    tabControl1.TabPages.Add(tpTab);
                
    TextBox ttBox = new TextBox(); ttBox.Text = (tabControl1.TabPages.Count 1).ToString();
                
    tpTab.Controls.Add(ttBox);
            } 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width