Jump to content

Programmatically create new page in tab control?


Noxious

Recommended Posts

Greetings,

I am trying to create a UI that can be used across many applications and am (thus far) unable to programmatically create/delete a new page on a tab control. Does anyone have any ideas on how to do this?

Thanks in advance.

You cannot create tabs dynamically (at Runtime) because it needs recompiling the code. You can only do it at development time. If in Dev environment, then there is a method for Adding/Removing tabs.

Search the forums to find the solutions proposed to get around this problem, it's been asked many times and based on your application, an alternative solution might already be out there waiting...Creating all your tabs beforehand and hiding some based on your different UIs is one of them.

Link to comment
  • 4 weeks later...

Here is what i have come up with for creating tabcontrol and pages at runtime in vb2005

Dim i As Integer

Dim temp As TabControl() = New TabControl(1) {}

Dim SComp2 As String() = Nothing

Dim CNT As Integer = 0

temp(CNT) = New TabControl

temp(CNT).Name = sString(3)

temp(CNT).Location = New System.Drawing.Point(Val(sString(5)), Val(sString(6)))

temp(CNT).Size = New System.Drawing.Size(Val(sString(7)), Val(sString(8)))

temp(CNT).Tag = Val(sString(2))

'temp(CNT).TextAlign = ContentAlignment.MiddleCenter

'temp(CNT).ForeColor = System.Drawing.Color.Black

'temp(CNT).BackColor = System.Drawing.Color.LightSalmon

SComp2 = sString(4).Split(";")

For i = 0 To SComp2.GetUpperBound(0)

temp(CNT).TabPages.Add(SComp2(i))

Next i

For Each ctrl As Control In SplitContainer1.Panel1.Controls

If TypeOf ctrl Is GroupBox Then

If CType(ctrl, GroupBox).Tag = Val(sString(1)) Then

CType(ctrl, GroupBox).Controls.Add(temp(CNT))

End If

End If

Next

Edited by ScubaBob
Link to comment

Here is what i have come up with for creating tabcontrol and pages at runtime in vb2005

Dim i As Integer

Dim temp As TabControl() = New TabControl(1) {}

Dim SComp2 As String() = Nothing

Dim CNT As Integer = 0

temp(CNT) = New TabControl

temp(CNT).Name = sString(3)

temp(CNT).Location = New System.Drawing.Point(Val(sString(5)), Val(sString(6)))

temp(CNT).Size = New System.Drawing.Size(Val(sString(7)), Val(sString(8)))

temp(CNT).Tag = Val(sString(2))

'temp(CNT).TextAlign = ContentAlignment.MiddleCenter

'temp(CNT).ForeColor = System.Drawing.Color.Black

'temp(CNT).BackColor = System.Drawing.Color.LightSalmon

SComp2 = sString(4).Split(";")

For i = 0 To SComp2.GetUpperBound(0)

temp(CNT).TabPages.Add(SComp2(i))

Next i

For Each ctrl As Control In SplitContainer1.Panel1.Controls

If TypeOf ctrl Is GroupBox Then

If CType(ctrl, GroupBox).Tag = Val(sString(1)) Then

CType(ctrl, GroupBox).Controls.Add(temp(CNT))

End If

End If

Next

And this helps someone with LabVIEW in what way?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.