0

Hello, I'm fairly new to VB.NET
I'm trying to add a textbox to a tabpage, which neither exist at design/compile time. The TabControl1 already exists, but the textboxes and tabpages don't. Here is my code so far (without any way to add the textboxes).

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

        Dim txtBoxNew As New TextBox
        Dim tabPageNew As New TabPage

        Me.TabControl1.TabPages.Add(tabPageNew)
        'add txtBoxNew to tabPageNew..

    End Sub

I declare a variable to the new textbox, but I don't know how to place it in tabPageNew.

Any pointers? Thanks,
-Dave

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by diyerxa
0

Hi,

Check this:

Dim NewTab As New TabPage
        Dim NewTextBox As New TextBox

        Me.TabControl1.Controls.Add(NewTab)
        NewTab.Controls.Add(NewTextBox)
0

Is there a difference between:

tabControl.TabPages.Add(NewTab)

and

tabControl.Controls.Add(NewTab)

?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.