Creating controls in a control array at run-time 
Author Message
 Creating controls in a control array at run-time

You should use dynamic array. To enlarge array you may use this:

ReDim Preserve CommandsArray([number of indexes])

After that you can still resize an array but remember to use 'Preserve'
keyword or you lost controls which are already in an array.
--
Dawid 'Dave' Lorenz -={ Zielona Gora, woj. lubuskie, PL }=-

http://www.*-*-*.com/ -={ SONIK.net-Internetowa Opinia Publiczna }=-
http://www.*-*-*.com/ { Dostepne tez w wersji offline }=-



Sat, 24 Feb 2001 03:00:00 GMT  
 Creating controls in a control array at run-time

Quote:
>How can controls be created in a control array at run-time?

>For example, I want to define a commandbutton array, e.g., command1(0), at
>design-time and then allocate more copies (or clones) of the commandbutton at
>run-time.

To Add controls I use:

Load Command1(X)
'X being the index of the control

To Get Rid of a control I use:

Unload Command(X)

You want to be sure and set the Left, Top properties (othewise the control will
appear at the same location as the original Command(0).

You will also want to change other properties (such as caption, height and
width)

Lastly to make the control appear make sure and set its visible property to
true (Visible is false by default when the control is loaded).

Enjoy,

Good Luck,

Chat
VB Developer for PC Scale

"Genius's and Fools, were all alike under God's eyes." - Unk



Sat, 24 Feb 2001 03:00:00 GMT  
 Creating controls in a control array at run-time
Dawid,
Totally BOGUS answer!!!
The answer is the Load statement as in:
    Load OptButton(NewButton) ' Create new item in array.
where NewButton is 1 greater than the previous largest index of the control
array!
Neila
Quote:

>You should use dynamic array. To enlarge array you may use this:

>ReDim Preserve CommandsArray([number of indexes])

>After that you can still resize an array but remember to use 'Preserve'
>keyword or you lost controls which are already in an array.
>--
>Dawid 'Dave' Lorenz -={ Zielona Gora, woj. lubuskie, PL }=-

>http://iop.sonik.net -={ SONIK.net-Internetowa Opinia Publiczna }=-
>http://free.polbox.pl/a/adlorenz -={ Dostepne tez w wersji offline }=-



Sun, 25 Feb 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. create & add controls array in run time

2. Creating Control Arrays At Run Time

3. Creating Controls at Run time using Collections not Arrays

4. Create Control Array and add item at run time

5. Creating control arrays at run time?

6. VB6 - Creating Control Array at Run Time

7. create a control array at run time

8. Creating array of controls at run time

9. Creating controls at runtime & Control arrays

10. Creating Controls at runtime & Control Arrays

11. Creating dynamic / runtime controls in control array

12. Creating ActiveX Controls at Runtime using a Control Array

 

 
Powered by phpBB® Forum Software