A question of form

  • Thread starter Thread starter Lorne Smith
  • Start date Start date
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
 
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?


System.Activator.CreateInstance

See also:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondynamicallyloadingusingtypes.asp
 
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
 
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
 
Back
Top