S
Soulless
I have added a method to my main form that is generic and will open a
window given the window name as a string. Unfortunatley, it fails...
Here is the method:
private void OpenWindow(string asFormName)
{
foreach (Form f in this.MdiChildren)
{
if (asFormName == f.GetType().ToString())
{
f.Activate();
return;
}
}
Form loForm =
(Form)Activator.CreateInstance(Type.GetType(asFormName));
loForm.MdiParent = this;
loForm.Show();
}
I call the method: OpenWindow("fornname");
This line fails: Form loForm =
(Form)Activator.CreateInstance(Type.GetType(asFormName));
I get: value cannot be null.
Any why I am getting null?
Thanks!
window given the window name as a string. Unfortunatley, it fails...
Here is the method:
private void OpenWindow(string asFormName)
{
foreach (Form f in this.MdiChildren)
{
if (asFormName == f.GetType().ToString())
{
f.Activate();
return;
}
}
Form loForm =
(Form)Activator.CreateInstance(Type.GetType(asFormName));
loForm.MdiParent = this;
loForm.Show();
}
I call the method: OpenWindow("fornname");
This line fails: Form loForm =
(Form)Activator.CreateInstance(Type.GetType(asFormName));
I get: value cannot be null.
Any why I am getting null?
Thanks!