Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6246277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:39:34+00:00 2026-05-24T12:39:34+00:00

I need to be able to programmatically create new tabs on a TabControl, add

  • 0

I need to be able to programmatically create new tabs on a TabControl, add controls to them, and be able to update the controls in each tab from another function. I already have a function to add tabs to the control, and to add controls to those tabs when they are created, but I’m stuck as to update the controls after they have been created.

EDIT: This is what I have to make the tabs and add the controls:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim tabpage As New TabPage
    tabpage.Text = "(empty)"

    Dim textbox1 As New TextBox
    Dim textbox2 As New TextBox

    textbox1.Parent = tabpage
    textbox2.Parent = tabpage

    textbox1.Location = New Point(10, 10)
    textbox2.Location = New Point(10, 30)

    TabControl1.TabPages.Add(tabpage)

End Sub

Urgh. I can’t seem to get back into the account I used to post this question, so I have to post my follow-up to Tim’s question in the comments for the previous answer as a new answer.
Debug.WriteLine(TabControl1.TabPages.Item(2).Controls.Find("textbox1", True).Count) returns 0. The tab and the controls have been created prior.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:39:34+00:00Added an answer on May 24, 2026 at 12:39 pm

    Ok – I’ll give it a shot, but I’m real rusty with WinForms, slightly less rusty with VB.NET. You’ll need to locate the control you want to update, and you should be able to do that through the Controls collection of the appropriate container – in this case, most likely a TabPage:

    TextBox tb1 = CType(tabpage.Controls.Find("textBox1", false), TextBox)
    tb1.Text = "I set the text!"
    

    Syntax might be slightly off, but hopefully this will at least point you in the right direction.

    See Control.ControlCollection.Find Method

    UPDATED

    Hans Passant suggested that this isn’t working because you didn’t set the Name property (I’m assuming he means the name of the controls, not the tab page). I did a little more reading on the ControlsCollection.Find method, and MSDN says “Searches for controls by their Name property and builds an array of all the controls that match.” You (and I) were trying to find the control by the instance name (textbox1, textbox2) – which were the instance names for the two controls, not the control names.

    So try this instead:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
        Dim tabpage As New TabPage
        tabpage.Text = "(empty)"
    
        Dim textbox1 As New TextBox
        Dim textbox2 As New TextBox
    
        textbox1.Parent = tabpage
        textbox2.Parent = tabpage
    
        textbox1.Location = New Point(10, 10)
        textbox2.Location = New Point(10, 30)
    
        textbox1.Name = "textbox1"
        textbox2.Name = "textbox2"
    
        TabControl1.TabPages.Add(tabpage)
    
    End Sub
    

    Then you can find the control using:

    TextBox tb1 = CType(TabControl1.TabPages.Item(TabControl1.TabPages.Count - 1).Controls.Find("textbox1", True)(0), TextBox) 
    tb1.text = "Test"
    

    Give that a try and see if it works for you. The key (and what I missed looking at your code last night as it was past my bedtime for me) was there was now way to identify the control in the Find method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to programmatically transcode mpeg-2 files to .mp4, .mp3, .wmv,
I need to be able to create basic MS Project items (tasks, projects, resources,
I need to create all the UI programmatically on demand, this means I can't
I want to programmatically parse and edit C++ source files. I need to change/add
Does anyone know how I can programmatically create a grid of squares. (each square
I'm using Apache.NMS 1.4. I need to be able to programmatically set the maximum
The title kinda sums it up--I need to be able to pro grammatically connect
I need to be able to get at the full URL of the page
I need to be able to get a list of the groups a user
I need to be able to merge two (very simple) JavaScript objects at runtime.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.