Dynamic control creation? 
Author Message
 Dynamic control creation?

I'm reading data files which contain polygon definitions and their associated
labels.  After drawing and filling each polygon on a form, I want to add the
label.

I would like to use a Label control, so as to be able to respond to events.
Since the number of polygons (and hence the number of labels) is unknown at
design time, I need to be able to dynamically create the required number of
labels.

An array of controls provides a dynamically sizable set of pointers to
labels, but I don't see how to create the Label controls given that
New doesn't work on them.

Any help, or pointers to docs or example code is appreciated.  I have
looked through the docs and through my VB Tips file (6/29/94).

Regards, Scott

--
 -----------------------------------------------------------

|   CompuServe: 76646,3451    |    Question the Media       |
 -----------------------------------------------------------



Tue, 27 May 1997 03:26:36 GMT  
 Dynamic control creation?
Quote:


...
>I need to be able to dynamically create the required number of labels.
>An array of controls provides a dynamically sizable set of pointers to
>labels, but I don't see how to create the Label controls given that
>New doesn't work on them.

....

Search of VBKB_FT on "control* near array*" finds a number of articles,
including Article ID: Q79029 "Creating Nested Control Arrays in Visual Basic"
This is THE article to read to understand control arrays (plus a number of
other neat concepts). In particular, look at the procedure "loadall_click"
________________________________________________________________________
Ayn Shipley, Toronto, Ontario    | Prevent computer viruses...         |



Tue, 27 May 1997 10:26:46 GMT  
 Dynamic control creation?

: Search of VBKB_FT on "control* near array*" finds a number of articles,
: including Article ID: Q79029 "Creating Nested Control Arrays in Visual Basic"
: This is THE article to read to understand control arrays (plus a number of
: other neat concepts). In particular, look at the procedure "loadall_click"

I looked at that article the other day and didn't think it was applicable.
I will look at it again more carefully...and thank you!

Regards, Scott

--
 -----------------------------------------------------------

|   CompuServe: 76646,3451    |    Question the Media       |
 -----------------------------------------------------------



Wed, 28 May 1997 02:43:12 GMT  
 Dynamic control creation?
Here is a snipit that does what you need,  or am I missing the point?

Function LoadSomeTextboxes( frm as Form, howmany% )

'here I pass the Form as a parameter, if code is not in the form's module
'keep in mind that one member of a control array must exist on the form in
'desgn mode indexed to 0.  trying to load a new control whose index exists
'will generate an error. The function returns the errorcode if err, 0 if no
'error  (my style,  I could not help myself!!)

        Dim i%

        On Error Goto err_loadsometextboxes
        Err = 0

        'control element 0 is on form,  perhaps not visible

        For i% =1 to howmany%

                load text1(i%)

                text1(i%).Top=text1(i%).height * i%             'this will stack them

                text1(i%).Visible = true                        'show it

        Next i%

err_loadsometextboxes:

        LoadSomeTextBoxes = Err
        On Error Goto 0
        Exit Function

End Function



Thu, 29 May 1997 02:05:33 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Dynamic Controls Creation and Referencing the new Control.

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

3. Dynamic Control Creation - Expand Form?

4. Dynamic control creation

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

6. VB6-Dynamic Control Creation

7. Dynamic control creation-HOW???

8. Dynamic control creation

9. dynamic control creation

10. Dynamic Control creation in eVB

11. Dynamic Controls Creation

12. Dynamic control creation

 

 
Powered by phpBB® Forum Software