Programming tutorials online .NET, Java, C++, Visual Basic, and More
 

Home
.NET Tutorials
General Programming Tutorials
Community/Forums
Site Extras

 

VB/VB.NET Forum
 

Open forum for discussing anything VB 6 or Visual Basic .NET related.


POST REPLY
Posted By: parwej   6/12/2006 4:31:00 AM
Reply To: yuuki who posted...
 
The maximum number of controls allowed on a single form depends on the type of controls used and available system resources. However, there is a fixed limit of 254 control names per form.

NOTE: Although you can have up to 254 control names in a form, a large number of controls in a form will severely degrade your program's performance. In some cases, you will experience out-of-memory error. To maximize the performance of your program, you should minimize the number of controls in each form.

Here are three ways to work around the control name and system resource limitations: • Use a control array - instead of using several instances of a control in a form, create a control array for all the similar controls on the form. Members of a control array share the same control name.
• Dynamically create the controls as required - instead of loading all the controls on a form when you first display the form, try loading the controls as needed. This only works well when you potentially need many controls, but will use only a few of them at any given time. For more information about dynamically creating controls, please see the following article in the Microsoft Knowledge Base:

190670 (http://www.kbAlertz.com/Feedback.aspx?kbNumber=190670/EN-US/) HOWTO: Dynamically Add Controls to a Form with Visual Basic 6.0
• Put your controls on a UserControl - similar to using a control array, you can create a UserControl that contains your controls and then add the UserControl to your project. For example, if you need a form that displays 500 text boxes, create a UserControl that contains 250 text boxes, and put two instances of your UserControl on the form. You now have 500 text boxes on the form, but only two controls.

Parwej Ahamad





 
Sign In
Email
Password
  Forgot my password

Search

Featured Book

Introducing Microsoft .Net, Third Edition ($19.79)
Introducing Microsoft .Net, Third Edition


Featured Software

Microsoft Visual Studio Standard 2005 ($249.99)
Microsoft Visual Studio Standard 2005