create a control array at run time 
Author Message
 create a control array at run time

Hello:
    Is there some methods in VB to create a control array such as
VB.CommandButton at run time? I try to use Add method, but it just can
create one control. and Load method need create a control array at design
time in advance.

thanks in advance.
--

Eric Peng (Wei gang)
Sotech Xi'an (XAFEC)
http://www.*-*-*.com/



Mon, 30 Sep 2002 03:00:00 GMT  
 create a control array at run time
If you use VB60 you can dynamicaly add controls at run-time using Add method
of controls collection:

examlpe:

   Form1.Controls.Add "VB.CommandButton", "cmdObj1", Me
   With Form1!cmdObj1
      .Visible = True
      .Width = 2000
      .Caption = "Dynamic Button"
   End With

or if you use older version of vb you can create command button with index=0
at design-time and then at run time load command with load statement.

example:

Dim i%
For i = 1 To 10
    Load Command1(i)
    Command1(i).Top = Command1(i - 1).Top + Command1(i).Height
    Command1(i).Visible = True
Next i

Tomislav Kralj,MCP


Quote:
> Hello:
>     Is there some methods in VB to create a control array such as
> VB.CommandButton at run time? I try to use Add method, but it just can
> create one control. and Load method need create a control array at design
> time in advance.

> thanks in advance.
> --

> Eric Peng (Wei gang)
> Sotech Xi'an (XAFEC)
> Http://www.future.com.cn



Mon, 30 Sep 2002 03:00:00 GMT  
 create a control array at run time
Thanks, however it doesn't solve my problem.
Add method just can create one control at run time, but not a control array.
And how can I use Add method to create another control that have got same
name and different index? or other way to get this perpose?
Thanks anyway.


Quote:
> If you use VB60 you can dynamicaly add controls at run-time using Add
method
> of controls collection:

> examlpe:

>    Form1.Controls.Add "VB.CommandButton", "cmdObj1", Me
>    With Form1!cmdObj1
>       .Visible = True
>       .Width = 2000
>       .Caption = "Dynamic Button"
>    End With

> or if you use older version of vb you can create command button with
index=0
> at design-time and then at run time load command with load statement.

> example:

> Dim i%
> For i = 1 To 10
>     Load Command1(i)
>     Command1(i).Top = Command1(i - 1).Top + Command1(i).Height
>     Command1(i).Visible = True
> Next i

> Tomislav Kralj,MCP



> > Hello:
> >     Is there some methods in VB to create a control array such as
> > VB.CommandButton at run time? I try to use Add method, but it just can
> > create one control. and Load method need create a control array at
design
> > time in advance.

> > thanks in advance.
> > --

> > Eric Peng (Wei gang)
> > Sotech Xi'an (XAFEC)
> > Http://www.future.com.cn



Tue, 01 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Creating controls in a control array at run-time

2. How to create a Control Array at Run Time?

3. create & add controls array in run time

4. Creating Control Arrays At Run Time

5. Creating Controls at Run time using Collections not Arrays

6. Create Control Array and add item at run time

7. Creating control arrays at run time?

8. VB6 - Creating Control Array at Run Time

9. Creating array of controls at run time

10. Adding elements to a control array of Menu items with subMenus at Run time

11. control arrays at run time

12. Run time error 340 - control array element does not exist

 

 
Powered by phpBB® Forum Software