Control Arrays
Control Arrays
Control Arrays
Control Arrays
Control Arrays
Control Arrays Control Arrays Control Arrays Control Arrays Control Arrays Control Arrays Control Arrays Control Arrays
Control Arrays Control Arrays
Control Arrays
Go Back  Xtreme Visual Basic Talk > > > Control Arrays


Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2009, 02:16 PM
realolman realolman is offline
Freshman
 
Join Date: Apr 2006
Posts: 46
Default Control Arrays


Could someone tell me how to do something similar to what was a control array in VB6 in .NET?

I would like to be able to fill the contents of several text boxes using a FOR NEXT loop or something similar..... corresponding the contents of an array with the texts of an equal number of text boxes.

I have been looking at articles by everybody and his brother, and I can't find anything that does anything like that.

thank you.
Reply With Quote
  #2  
Old 02-17-2009, 03:22 PM
user name user name is offline
Junior Contributor
 
Join Date: Sep 2004
Posts: 264
Default

Theres probably a few ways, here are two
Code:
Private TB() As TextBox

 TB = New TextBox() {Me.TextBox1, Me.TextBox2, Me.TextBox3, Me.TextBox4}
Code:
Private TB As New List(Of TextBox)

TB.Add(Me.TextBox1)
TB.Add(Me.TextBox2)
TB.Add(Me.TextBox3)
TB.Add(Me.TextBox4)
Both loop the same
Code:
 For i As Integer = 0 To TB.Count - 1
            TB(i).Text = i.ToString
        Next
Reply With Quote
  #3  
Old 02-17-2009, 04:50 PM
AtmaWeapon's Avatar
AtmaWeaponControl Arrays AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

user_name is correct. There is no designer support for control arrays in Visual Studio .NET, but the .NET framework supports arrays of controls; you just have to code them yourself.

Have a look at IcePlug's Control Arrays in .NET tutorial for more detailed information.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #4  
Old 02-20-2009, 03:06 PM
realolman realolman is offline
Freshman
 
Join Date: Apr 2006
Posts: 46
Default

Where do you put this stuff?

I am getting complaints... Private not valid on a local variable declaration

and TextBox 1,2 ,3,and 4 not a member of TextBox array.Form 1

NEVER MIND...

I didn't realize what you were doing...user_name, I expected the code you posted to create and display the textboxes..... I see what you are doing now, and I believe this will be just what I wanted... thank you : )

Last edited by realolman; 02-20-2009 at 03:22 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Control Arrays
Control Arrays
Control Arrays Control Arrays
Control Arrays
Control Arrays
Control Arrays Control Arrays Control Arrays Control Arrays Control Arrays Control Arrays Control Arrays
Control Arrays
Control Arrays
 
Control Arrays
Control Arrays
 
-->