Dynamically add TabPage if TabPage doesn't exist on TabControl

  • Thread starter Thread starter mmatin2411
  • Start date Start date
M

mmatin2411

Guest
Hi,

I need to dynamically add TabPage and TextBoxes to specific TabPage. I have two fields from database, Field Name and Category name. Category name is TabPage and Field Name is TextBox. I could have different Field Name with same Category name. I want to add TabPage(Category name) and TextBox (Filed Name) if TabPage doesn't exist or add TexBox(FiledName) to existing TabPage. I'm struggeling to do that. Anyone can help.

Data:

Category name Fiedl Name

Product Commodity name 1

Product Commodity name 2

Product Commodity name 3

Barcode Barcode 1

Barcode Barcode 2

Barcode Barcode 3


Code:

Dim LabelLocation As Integer = 17
Dim Count As Int16 = 0
Dim TextBoxLocation As Integer = 10
Dim Nr As Integer = 1
For i = 0 To frmDEL.ListViewTemplate.Items.Count - 1
Dim TabPageNr As New TabPage
With TabPageNr
.Name = "TabPage" & CStr(Count)
.Font = New Font("Microsoft Sans Serift", 12, FontStyle.Bold)
.Text = frmDEL.ListViewTemplate.Items(i).SubItems(1).Text
End With
TabControl1.Controls.Add(TabPageNr)
Dim LabelData As New Label
With LabelData
.Name = "LabelData" & CStr(Count)
.Size = New Size(200, 25)
.Location = New Point(5, LabelLocation)
.Font = New Font("Microsoft Sans Serift", 12, FontStyle.Bold)
.Text = frmDEL.ListViewTemplate.Items(i).Text
End With
Dim TextBoxData As New TextBox
With TextBoxData
.Name = "TextBoxData" & CStr(Count)
.Size = New Size(1025, 31)
.Location = New Point(325, TextBoxLocation)
.Font = New Font("Microsoft Sans Serift", 16, FontStyle.Regular)
If LabelStatus.Text = "EditItem" Then
.Text = frmDEL.ListViewTemplate.Items(i).SubItems(3).Text
End If
End With
TabPageNr.Controls.Add(LabelData)
TabPageNr.Controls.Add(TextBoxData)
LabelLocation = LabelLocation + 40
TextBoxLocation = TextBoxLocation + 40
Count += 1
Nr += 1
Next
TabControl1.SelectedIndex = 0

Mario

Continue reading...
 
Back
Top