Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a major problem...how to manage a form with over 500 textboxes.

 

Initially, I created all of the objects on the form itself, but to give tham all a meaningful name is painful.

 

I then created the textboxes through coding using arrays.

 

This would seem to be the best way, although, how do you access a particular txtbox in the code.

 

I have a sub where the textboxes are loaded in and manipultaing them in that sub is fine, but how do you acccess them from another sub.....since they dont really exist until the form is loaded.

 

Maybe there is a better way to do this though....

 

Any comments or suggestions would be greatly appreciated

 

Steve

Posted

I think I understand, so here's a shot...

 

You're using an array to manage your TextBoxes right? That's good since you have so many. Your array should be declared at the top of the class outside of all methods (but still inside the class, obviously). In your constructor, initialize the array with all of your TextBoxes, then add them to whatever container necessary so they are displayed when the form loads.

 

You should be able to access your array of TextBoxes from anywhere within the class, even before the form is fully visible. Once your class is instantiated, your TextBoxes will be instantiated as well (from your constructor), then you can use them from then on.

 

Did I misunderstand your problem? Please explain a little better if I did.

Gamer extraordinaire. Programmer wannabe.
Posted

No, you have got it right.

 

I think I have figured out a simpler and quicker way though...have the standard set of textboxes with the fields required at the bottom and use a listview/listbox to fill the rest of the form to show each records entered in the form....less coding and memory usage that way.

 

Thanks anyway, good to know how to solve that problem

 

Steve

Posted

Its a form with 15 people on it and each person has about 10 fields required to be filled in. It is on a tabpage, with 4 pages and these fields are on each one.

 

I have looked at grid view but don't like it. I have decided to use a listview instead, but have the required fields at the bottom of the form and then have a button to add/delete them to the listview.

  • *Gurus*
Posted
My thoughts: There shouldn't be separate controls for each person, instead there should be a set of controls for one person, and they should be populated when each person is selected from a combo box at the top of the form.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...