Dynamically Creating Controls at Runtime 
Author Message
 Dynamically Creating Controls at Runtime

I have an application where I would like to create controls on a form at runtime.
I am not certain how many controls and what types of controls I will need until
then, because it is table driven.  I know that I cannot do the following:

Dim newTextBox as New Textbox

All object variables need to be set to point to existing instances of the basic
controls, and the New keyword cannot be used to create new controls.  Are there
any tricks to do this?

Thanks in advance,

Ryan Sutter


have limited Usenet access.



Sun, 28 Feb 1999 03:00:00 GMT  
 Dynamically Creating Controls at Runtime

Actually, you are very close. The code "Dim newTextBox as New Textbox" will
work if you create a Text Box, at design time, called newTextBox AND make
it the first member of a control array, i.e. set the Index property to 0.
Then each time you dimension a new Text Box the Index property will be
incremented automatically. You then use the Index property to tell which
Text Box you are accessing.



Quote:
> I have an application where I would like to create controls on a form at
runtime.
> I am not certain how many controls and what types of controls I will need
until
> then, because it is table driven.  I know that I cannot do the following:

> Dim newTextBox as New Textbox

> All object variables need to be set to point to existing instances of the
basic
> controls, and the New keyword cannot be used to create new controls.  Are
there
> any tricks to do this?

> Thanks in advance,

> Ryan Sutter

> P.S. - If you have a suggestion, please e-mail me at


- Show quoted text -

Quote:
> have limited Usenet access.



Mon, 01 Mar 1999 03:00:00 GMT  
 Dynamically Creating Controls at Runtime

Quote:
>Actually, you are very close. The code "Dim newTextBox as New Textbox" will
>work if you create a Text Box, at design time, called newTextBox AND make

No, the New keyword is not valid on controls.  You are correct about
requiring a control array, but the syntax for creating a new text
object is:

Load newTextBox(1)

newTextBox(1).Move 2000
newTextBox(1).ZOrder 0
newTextBox(1).Text = "Just Created"
newTextBox(1).Visible = True



Tue, 02 Mar 1999 03:00:00 GMT  
 Dynamically Creating Controls at Runtime



Quote:
> I have an application where I would like to create controls on a
form at runtime.
> I am not certain how many controls and what types of controls I
will need until
> then, because it is table driven.  I know that I cannot do the following:
> Dim newTextBox as New Textbox

Ryan,

Looks like you need one of every possible control on the form at
design-time. Then you could do:

   Dim newTextBox as new text1

Steve.



Tue, 02 Mar 1999 03:00:00 GMT  
 Dynamically Creating Controls at Runtime

Lookup ControlTemplate object in VB Help

Jeremy H



Sat, 06 Mar 1999 03:00:00 GMT  
 Dynamically Creating Controls at Runtime

I have seen this Problem Addressed in the following way

Create a Control array with one element for each control you want to
create. Then when the time comes to create the controls you simply load
another instance of the control array of the type you want.

This may waste some space (ie declaring controls which you may not use)
but this strategy has been successfuly implememted.



Mon, 08 Mar 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. deleting dynamically created controls in runtime using vb.net

2. Can I dynamically(runtime) create a form/control?

3. Dynamically Creating Controls and Forms at runtime - HELP!!!!

4. HELP: Dynamically Creating an enumerating Menu Items during Runtime

5. Create a new form dynamically at runtime via strFormName

6. How to dynamically create a menu at runtime

7. Dynamically creating check boxes at runtime

8. Create a new form dynamically at runtime via strFormName

9. Dynamically adding controls at runtime.

10. Dynamically Registering Controls - Runtime

11. Dynamically Registering Controls - Runtime

12. Dynamically adding a custom control to a form during runtime

 

 
Powered by phpBB® Forum Software