Solved

Dynamically adding controls to a Collection

Posted on 2006-11-03
1
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 17867199
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

719 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