Solved

Dynamically adding controls to a Collection

Posted on 2006-11-03
1
223 Views
Last Modified: 2010-04-23
I need to dynamically (at run time) create a large amount of textboxes.  I want to create a loop which adds the controls (textboxes in this case) to a collection.  How can I do this?  I know I can loop through and create differest control names, text, etc., but I can't figure out how to use a loop to generate different actual controls.  As an example:

I tried this:

for i = 1 to txtBoxAmt
txtBoxCollection.add(textbox1) . . . . I can't modify "textbox1" using the count varible "i".  Any ideas?
textbox1.name = "name" & i"
textbox1.text = "text" & i"
Next

Please help.  THANKS!
0
Comment
Question by:mgb1000
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
Comment Utility
Dim tb As TextBox
For i As Integer = 1 To txtBoxAmt
    tb = New TextBox
    tb.Name = "Name" & i
    tb.Text = "Text" & i
    txtBoxCollection.add(tb)
Next
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now