Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a Control Array at Run Time
Message
Information générale
Forum:
Visual Basic
Catégorie:
Contrôles ActiveX
Divers
Thread ID:
00149272
Message ID:
00149295
Vues:
18
>I wish to create a control array at run time, with or without having a first control placed onto my form. Here is an example :
>
>Consider creating an array of option butons.
>I read a recordset, containing payment modes (i.e. Card, Check, Cash,...). i don't know at first how items there are into the recordset.
>I want to use recordcount to set the max items into my array.
>And I want to set payment text to the caption, and key to the index, i.e. Cash, 2, Check, 3, and so on.
>
>I've look at MS Online Books, but did not find anything.
>
>Help would be highly appreciated

If you use VB5, place a control (for example a text box) on your form with the index set to 0 (or something else different than null). Then when you need a new control, you use the following syntax:
Load Text1(1)
Text1(1).Top = Text1(0).Top + Text1(0).Height + 120
Text1(1).Visible = True
Your new control will have the same properties as the first one on your form except that the index will be the one you gave on the load statement and it will be invisble.

The same way you can unload the controls you created by using Unload Text1(1).

If you use VB6, I have read that you can create a new control on form without already having one instance created but I didn't know more at that time.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform