sjn78 Posted June 1, 2003 Posted June 1, 2003 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 Quote
wyrd Posted June 1, 2003 Posted June 1, 2003 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. Quote Gamer extraordinaire. Programmer wannabe.
sjn78 Posted June 1, 2003 Author Posted June 1, 2003 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 Quote
wyrd Posted June 1, 2003 Posted June 1, 2003 Ah, good. Quote Gamer extraordinaire. Programmer wannabe.
*Gurus* divil Posted June 1, 2003 *Gurus* Posted June 1, 2003 Good lord, 500 textboxes? Can I ask what this is for? Have you considered using a grid or list-style control instead? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
sjn78 Posted June 2, 2003 Author Posted June 2, 2003 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. Quote
*Gurus* divil Posted June 2, 2003 *Gurus* Posted June 2, 2003 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.