Re: Programatically design a form
- From: "Ken Halter" <Ken_Halter@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 5 Jul 2005 10:03:48 -0700
"Peter T" <peter_t@discussions> wrote in message
news:OGfbm3XgFHA.2472@xxxxxxxxxxxxxxxxxxxxxxx
> Thanks for the tip. Unfortunately it does not appear from Ken's response
> to
> be possible to use a Control Array to create a form other than at run
> time,
> as opposed to a form that I can save which is what I want to do.
>
> Regards,
> Peter T
You can only create "True" control arrays at design time. You can only
create an array of controls at runtime (not a control array)... confusing?
For example. Here's one of the event handlers for a "True" control array.
Notice the Index argument.
Private Sub Command1_Click(Index As Integer)
End Sub
There's no way to set up WithEvents to work with an array so controls added
to an array at runtime, using Controls.Add won't be able to support events.
There are ways around that.... anyway. There's no way to save a form, as a
form, at runtime. You add the code to create the controls, and leave it
there for good. Every time that form loads, all controls will be re-created.
One issue is, VB is a fully compiled language. The concept of a "frm" or
"frx" file no longer exists once it's compiled. That means you can't reallt
save any results from anything you've done at runtime and expect that to be
there the next time the form loads.
To add controls to a "True" control array at runtime, use Load instead of
Controls.Add... here's an extremely "bare bones" sample...
Add Controls at Runtime
http://www.vbsight.com/Code.htm
...to get event behavior from controls you add using Controls.Add, without
setting a WithEvents variable for each, you can use something similar to the
code shown in.....
Share Events by using Implements
http://www.vbsight.com/Code.htm
Another that may help is... Add Controls at Runtime With Events (kind of) on
that same page (time to break up that page and add better descriptions)
--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..
.
- Follow-Ups:
- Re: Programatically design a form
- From: Patrick Pirtle
- Re: Programatically design a form
- From: John B
- Re: Programatically design a form
- From: Peter T
- Re: Programatically design a form
- References:
- Programatically design a form
- From: Peter T
- Re: Programatically design a form
- From: J French
- Re: Programatically design a form
- From: Peter T
- Programatically design a form
- Prev by Date: Re: Functional IDE DLL call compiles to non-functional DLL call
- Next by Date: Re: Functional IDE DLL call compiles to non-functional DLL call
- Previous by thread: Re: Programatically design a form
- Next by thread: Re: Programatically design a form
- Index(es):
Relevant Pages
|