Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Cannot add anymore controls in the form...?!

mOskimOski Member Posts: 44
I'm making a program and I'm using alot controls and recently I discovered that I can't add anymore controls.... This I a VERY BIG problem for me because I still need more controls for my program...

Is there anyway to make VB add more controls to the form that I'm using....

neEd heLp....

Comments

  • rushenttrushentt Member Posts: 33
    There is a limit of 254 controls per form.
    The following is an extract from the MSDN article on this:-

    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:

    Q190670 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.

    Rgds
    Terry

    : I'm making a program and I'm using alot controls and recently I
    : discovered that I can't add anymore controls.... This I a VERY BIG
    : problem for me because I still need more controls for my program...
    :
    : Is there anyway to make VB add more controls to the form that I'm
    : using....
    :
    : neEd heLp....
    :
  • mOskimOski Member Posts: 44
    : I'm making a program and I'm using alot controls and recently I
    : discovered that I can't add anymore controls.... This I a VERY BIG
    : problem for me because I still need more controls for my program...
    :
    : Is there anyway to make VB add more controls to the form that I'm
    : using....
    :
    : neEd heLp....
    :

    I just read the article, thank you sooo mUch for the advice!
    hehe

    (^_^)
Sign In or Register to comment.