Dynamic Creation of Controls 
Author Message
 Dynamic Creation of Controls

I need a way to create a form at runtime, adding any number of controls,
in particular the 3-D pushbutton.  I want to put 1,2,3 or maybe 100
pushbuttons.  But I don't want to do this at design time, but at runtime.

I have concluded that this is impossible to do in VB.  Does anyone know
how to do this?



Tue, 24 Feb 1998 03:00:00 GMT  
 Dynamic Creation of Controls


Quote:
>I need a way to create a form at runtime, adding any number of controls,
>in particular the 3-D pushbutton.  I want to put 1,2,3 or maybe 100
>pushbuttons.  But I don't want to do this at design time, but at runtime.

>I have concluded that this is impossible to do in VB.  Does anyone know
>how to do this?

Yes it is possible. First you need to draw at least one control and make it a
control array with index 0. Here is a code snippet to add 5 additional command
buttons, give each a caption and position each. Each execution of the Load
statement will create a new control adding it to the control array.

For i = 1 To 5
    Load cmdButton(i)
    cmdButton(i).Caption = "Button " & i
    cmdButton(i).Left = (Calculate left position here)
    cmdButton(i).Top  = (Calculate top position here)
Next

Jay

*****************************************************************


* New York, NY                   http://www.panix.com/~logical  *
*****************************************************************



Thu, 26 Feb 1998 03:00:00 GMT  
 Dynamic Creation of Controls

Quote:

>I need a way to create a form at runtime, adding any number of controls,
>in particular the 3-D pushbutton.  I want to put 1,2,3 or maybe 100
>pushbuttons.  But I don't want to do this at design time, but at runtime.
>I have concluded that this is impossible to do in VB.  Does anyone know
>how to do this?

I don't think you can do this completely as you describe above. You
can add a new form, as below:

        Dim Frm as Form
        Set Frm = New Form1

and you can add controls to an existing control array.  Maybe you can
create a form with a 3D pushbutton control array with a single,
non-visible element (3Dbutton(0).Visible = False), then make it
visible and then add new members of the control array.

JR


SkillAdvance Ltd. - +44 181 446 6481            Fax: +44 181 446 9143



Sat, 28 Feb 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. dynamic creation of controls?

2. Dynamic creation of Control Array on a SSTab

3. Dynamic creation of Controls

4. Dynamic Creation of Controls

5. Dynamic Controls Creation and Referencing the new Control.

6. Dynamic Control Creation, Controls object has no .Add ???

7. Dynamic creation of web controls in VB.NET

8. Dynamic Control Creation - Expand Form?

9. Dynamic control creation

10. Dynamic control creation and calling DOS programs from VB.

11. VB6-Dynamic Control Creation

12. Dynamic control creation-HOW???

 

 
Powered by phpBB® Forum Software