A question of form

L

Lorne Smith

Hi, I have a question about instantiating forms.

I have a particular issue where I must load a form, but the name of the form
is held in a variable (our app uses differently laid out forms for different
sites, so the name of the form to load is held in a resource.

If VB6, I did the following:

Dim lForm As Form

Set lForm = Forms.Add(pFormName)
lForm.Show

pFormName is a string variable holding the actual name of the form. This
allows me to add an instance the form to the forms collection and then
handle it as any other form.

As the Forms collection is dead & gone in .NET, how would I achieve the same
result?

Thanks

Lorne
 
R

Rigga

Check out Assembly.Creatinstance in the docs.. that should do what your
looking for.

along the lines of
x as form = [Assembly].GetExecutingAssembly.CreateInstance("FormName")
 
A

Armin Zingler

Lorne Smith said:
Hi, I have a question about instantiating forms.

I have a particular issue where I must load a form, but the name of
the form is held in a variable (our app uses differently laid out
forms for different sites, so the name of the form to load is held in
a resource.

If VB6, I did the following:

Dim lForm As Form

Set lForm = Forms.Add(pFormName)
lForm.Show

pFormName is a string variable holding the actual name of the form.
This allows me to add an instance the form to the forms collection
and then handle it as any other form.

As the Forms collection is dead & gone in .NET, how would I achieve
the same result?


System.Activator.CreateInstance

See also:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondynamicallyloadingusingtypes.asp
 
L

Lorne Smith

Thanks loads :) I'll give it a try!

Lorne

Rigga said:
Check out Assembly.Creatinstance in the docs.. that should do what your
looking for.

along the lines of
x as form = [Assembly].GetExecutingAssembly.CreateInstance("FormName")


Lorne Smith said:
Hi, I have a question about instantiating forms.

I have a particular issue where I must load a form, but the name of the form
is held in a variable (our app uses differently laid out forms for different
sites, so the name of the form to load is held in a resource.

If VB6, I did the following:

Dim lForm As Form

Set lForm = Forms.Add(pFormName)
lForm.Show

pFormName is a string variable holding the actual name of the form. This
allows me to add an instance the form to the forms collection and then
handle it as any other form.

As the Forms collection is dead & gone in .NET, how would I achieve the same
result?

Thanks

Lorne
 
C

Cor

Hi Armin,

Will you look at that form question from Stan Sainte Rose?
It is something special with a MDI and you know that I never use that.
He did not start it as a MDI question otherwise I would not have answered
it.
And more, it sound as something strange.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top