textbox array

  • Thread starter Thread starter barbara
  • Start date Start date
B

barbara

Hi all,

I need to use hundreds of textboxes to display data. In VB 6.0, I can
assign the value by the loop with a textboxes array. How to do it in
VB.net?

Thanks a lot.
 
The textboxes ( like other controls ) are contained in Me.Controls.


For Each c as Control In Me.Controls

'Do your stuff here

Next

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
Hi,

I dont think having hundreds of textboxes is a good idea. Here is a
link on how to create a control array.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet05132003.asp

Control array control
http://www.windowsforms.com/default.aspx?tabindex=6&tabid=47&ItemID=16&mid=142

How to loop through controls on Form. Uses recursion to check for textboxes
on controls like panels.

CheckForTextBox(Me.Controls)



Private Sub CheckForTextBox(ByVal ctrls As Control.ControlCollection)

For Each ctrl As Control In ctrls

If TypeOf ctrl Is TextBox Then

DirectCast(ctrl,TextBox).Text="My New Value"

End If

CheckForTextBox(ctrl.Controls)

Next

End Sub


Ken
--------------------
Hi all,

I need to use hundreds of textboxes to display data. In VB 6.0, I can
assign the value by the loop with a textboxes array. How to do it in
VB.net?

Thanks a lot.
 
barbara said:
I need to use hundreds of textboxes to display data. In VB 6.0, I can
assign the value by the loop with a textboxes array. How to do it in
VB.net?


Can I suggest you re-think your design? Why do you need hundreds of
textboxes? The user can not possibly enter text in 100 different places
all at the same time.

Take note of the property grid in the IDE, it shows property names
and their values, where some of them are text values. When the values
need to be displayed, a lable or (in this case) a grid can be used. When
user input is needed, that is where a texbox is displayed and used....

FWIW, there is a Property grid control you can use, you simply need
to add it to your toolbox, it is not there by default. Read up on its use,
you may like it!

LFS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top