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

  • SEARCH
  • Home
  • 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 8482387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:48:50+00:00 2026-06-10T19:48:50+00:00

make my own UserControl and I can aggregate new TabPages to a TabControl and

  • 0

make my own UserControl and I can aggregate new TabPages to a TabControl and then, inside of then TabPage, I add my own UserControl using the following code.

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim TabX As New Windows.Forms.TabPage("Tab " & TabCount.ToString) '(ConfiguracionTabPage)
    Dim MyControl As New ClientesEmpresa
    MyControl.Name = "Control" & TabCount.ToString

    If ClientesTabControl.TabPages.Count = 10 Then
        ClientesTabControl.TabPages.RemoveAt(9)
    End If
    TabX.Controls.Add(MyControl)

    TabX.Name = "Tab" & TabCount.ToString
    TabX.Text = "Tab" & TabCount.ToString

    MyControl.TitularLbl.Text = "Coca Cola"

    Me.ClientesTabControl.TabPages.Insert(0, TabX)
    Me.ClientesTabControl.SelectedIndex = 0
    TabCount += 1
End Sub

My user control have several Labels, TextBox and TabPages(inside of a TabControl).

Now I want to change some properties dynamically from the source code, but I don’t know how to access them.
The most similar theme that I found is this How to Acces of an User control in c#, but, as the title says, is in C#, how I can do it in VB.NET?


Sorry, I just notice that the Enter key post the comment. 🙁

Thanks for your feedback, I understand what are you saying but I missing something in the middle.

When I create the control in running time in the above code I can access easily to the properties of the created object, in this case my UserControl, but I don’t understand how to reach the properties of a particular instance of that control from outside of Button_Click; ie. another button_click event(second button)

I was thinking to use something like

Dim ControlList As Windows.Forms.Control() = Me.ClientesTabControl.TabPages(0).Controls.Find("ModeloLbl", True)

or

ClientesTabControl.TabPages(0).Controls.OfType(Of AlarmasVehiculo)()

But I’m stuck here.

————————————- 3th post —————

Thanks Steve, I was resolved using “Control.Find” and a For Each but your solution is easier.

There’s any way to get the name of the selected tab or I must to create an Array when I create the New TabPage?, the idea is to update the text of the controls inside of the selected tab only when is selected by the user or every 5 seconds but just the in selected one.

Thanks.

  • 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-06-10T19:48:52+00:00Added an answer on June 10, 2026 at 7:48 pm

    To borrow M4N’s answer from the C# question, and translate it to VB:

    Cleanest way is to expose the desired properties as properties of your usercontrol, e.g:

    Public Class MyUserControl
        ' expose the Text of the richtext control (read-only)
        Public ReadOnly Property TextOfRichTextBox As String
            Get 
                Return richTextBox.Text
            End Get
        End Property
    
        ' expose the Checked Property of a checkbox (read/write)
        Public Property CheckBoxProperty As Boolean
            Get 
                Return checkBox.Checked
            End Get
            Set (value As Boolean)
                checkBox.Checked = value
            End Set
        End Property
    
        '...
    End Class
    

    In this way you can control which properties you want to expose and whether they should be read/write or read-only. (of course you should use better names for the properties, depending on their meaning).

    Another advantage of this approach is that it hides the internal implementation of your user control. Should you ever want to exchange your richtext control with a different one, you won’t break the callers/users of your control.

    To answer your second question, if you need to access your dynamically created controls, you can do so easily using their names, for instance:

    Dim c As ClientesEmpresa= CType(Me.ClientesTabControl.TabPages("Tab1").Controls("Control1"), ClientesEmpresa)
    c.CheckBoxProperty = True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make my own linkedlist implementatin in c++ using templates. However, I
can I make my own headers in HTTP request ? e.g. This is normal
Can I make my own jabber server.So that if I run my website xyz
I used to make my own layout for managing loading pages inside the index
To make my own assemblies appear in the .NET tab's list of Add Reference
I want to make my own malloc/free so I can make a precise copying
How can I make my own delete method to prevent that the data really
how can i make a user control to run on its own thread ?
i wanna make my own application to reach my mails. i'm using office 365
Can we make our own List<string, string, string> in C#.NET? I need to make

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.