Re: Programatically design a form

Tech-Archive recommends: Fix windows errors by optimizing your registry



"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..


.



Relevant Pages

  • Re: Help with optiongroups
    ... You can poll each named option button by name or if they're in a control array use the array indexes: ... For option controls on a form if you want more than 1 set of options you must put each set inside of frame controls otherwise all the options other than the selected one will be False. ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Programatically design a form
    ... > create an array of controls at runtime... ... Here's one of the event handlers for a "True" control array. ... Every time that form loads, ... VB is a fully compiled language. ...
    (microsoft.public.vb.general.discussion)
  • Re: Original Jazz Bass Control Plate
    ... yeah it's cheaper but not THAT much cheaper! ... tone controls short together when volumes are max and the volumes ... interact with the tone controls. ... J-Bass control array. ...
    (alt.guitar.bass)
  • RE: Design Time Control Arrays
    ... I think whether you set up these controls at design-time or at run-time, ... you could always add them to a Control array or colleciton. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Bug in .NET Tab Control? Help!
    ... The form loads, instantiates a bunch of worker threads that execute one at a ... datagrids on 5 different tab pages in a tab control. ... Controls created on one thread cannot be parented to ...
    (microsoft.public.dotnet.languages.csharp)