Click here to Skip to main content
13,549,853 members
Rate this:
Please Sign up or sign in to vote.
See more:
I used this reader to check Record Count,

While QReaderQ.Read()
RecCount = RecCount + 1 ' Count How many Rows
End While

Add Tab Pages Equal of Records

For xXx = RecCount To 1 Step -1 ' to Desending Order ---->3,2,1
newPage = New TabPage 'create new instance
If xXx = 1 Then
newPage.Text = "Repeat - 1"
newPage.Text = "Repeat - " & xXx.ToString
End If

Now I Created Tab Pages to equal number of Records.
I Need to Create Text Boxes in separate Tab Page and insert Data Base Field Data to that Text Boxes. What is way to do that ?
Posted 26-Apr-13 8:42am
Sergey Alexandrovich Kryukov 26-Apr-13 15:36pm
You need to provide fully-qualified type name for "TabControl". There are more then one type under this simple name. Always tag your UI library.
pradeep20912 26-Apr-13 15:44pm
Sir, I can't Understand what you meaning

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If I understand you correctly, you want one textbox on each tab page?

If so, then just declare a new textbox control, set it's properties (font, size, anchoring, docking, etc) and add it to the tab page.

Since you are adding an unknown number of tab pages/textboxes, I suggest creating a method that creates the new tab, adds the textbox, sets any properties, and then adds it. That way you can call that one function as many times as you need.

If you are going to want the textboxes that you add to the tab pages to have events that you code for, you'll also want to add event handlers when you're adding it.

Here is a smaple of code I use to do something similar. But I use a richtextbox instead. I also have three different events that I'm tying to the richtextboxes. I didn't include the code for those, but they would look like any other textchanged, keydown, keypress event for a richtextbox.

Dim tpNew As New TabPage(strTabName)
tpNew.Controls.Add(New RichTextBox)
tpNew.Padding = New Padding(3)
tpNew.BackColor = Color.FromKnownColor(KnownColor.Control)
tpNew.ContextMenuStrip = mnuBuildYourOwn 'I havea right click menu on my tab pages

Dim rtxt As RichTextBox = CType(tpNew.Controls(0), RichTextBox) 'Adds RichTextbox to new tab page
rtxt.Dock = DockStyle.Fill
rtxt.Font = gblFont
rtxt.BorderStyle = BorderStyle.FixedSingle
rtxt.ContextMenuStrip = mnuUserText 'I have a right click menu on my textboxes
rtxt.DetectUrls = False
rtxt.AcceptsTab = True

'Remove handlers before adding again to ensure that the event will only be run once
RemoveHandler rtxt.TextChanged, AddressOf richtextbox_TextChanged
RemoveHandler rtxt.KeyDown, AddressOf FieldName_KeyDown
RemoveHandler rtxt.KeyPress, AddressOf ManualSQL_KeyPress

'Connect handlers to the proper methods
AddHandler rtxt.TextChanged, AddressOf richtextbox_TextChanged
AddHandler rtxt.KeyDown, AddressOf FieldName_KeyDown
AddHandler rtxt.KeyPress, AddressOf ManualSQL_KeyPress

'Creating a new tab page at the end
tcBuildYourOwn.TabPages.Insert(tcBuildYourOwn.TabPages.Count - 1, tpNew)

Hope this helps.
pradeep20912 26-Apr-13 17:38pm
Thank You,
I tried it, but I don't know some thing wrong with me, I am just starting my VB.Net studies.

I want to create Tab Pages with Data Base Field Data. We don't know how many rows in the data base for single person.

Ex. If DataBase has 03 rows, (also Field "Person ID", "Repeat Time", "Company") I need to put these all Fields Data in to 03 Tab Pages, then 03 rows mean 03 Tab Pages and different Details.
Kschuler 29-Apr-13 8:56am
So which part are you stuck on? Pulling the data from the database? Looping through the data? What database are you using? I see you have a reader object that you are using to get the record count. That could be your loop right there. Each time you loop through one of those records you can access the data in the record. (Personally I prefer to fill a datatable and loop through it with a For Each statement.)
pradeep20912 30-Apr-13 3:42am
Please show me how to use datatable with loop for my requirement. In my post I mention code what I use to create Tab Page.
after I need create no of TextBoxes to equal of Rec. Count. Then I want to show MS-Access Column data in that Textboxes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180515.1 | Last Updated 26 Apr 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100