A
Ahmet
Hi all;
I have one application in which I read form names from database to be opened.
I open form with the code below, and call its show method for form to be shown
but before this, I must set MdiChild property to true to make this form child
I can call functions as you can see like (show), how can i set.MdiParent = this property of dynamically loaded form ?
Or I can call a form function dynamically with parameter ?
/*------------------------------------------------------------------------*/
public void OpenForm(string pi_form_dll_name)
{
bool bFindForm = false; Assembly formAsm = null;
try
{
this.Cursor = Cursors.WaitCursor;
formAsm = Assembly.LoadFrom(pi_form_dll_name + ".dll");
Type[] ClassTypes = formAsm.GetTypes();
foreach(Type clsType in ClassTypes)
{
if (clsType.IsSubclassOf(typeof(Form)))
{
object o = System.Activator.CreateInstance(clsType);
MethodInfo mi = clsType.GetMethod("Show"); // here can we invoke property of MdpParent=this instead of invoking method ?
mi.Invoke(o, null); bFindForm = true; break;
}
}
if (bFindForm == false)
{
string sErr = pi_form_dll_name + ".dll does not have " +
"Form-derived class defined";
MessageBox.Show("Form Open Error",sErr);
}
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message,"Form Open Error");
}
finally
{
this.Cursor = Cursors.Arrow;
}
}
/*------------------------------------------------------------------------*/
helps'll be appreciated..
Ahmet
I have one application in which I read form names from database to be opened.
I open form with the code below, and call its show method for form to be shown
but before this, I must set MdiChild property to true to make this form child
I can call functions as you can see like (show), how can i set.MdiParent = this property of dynamically loaded form ?
Or I can call a form function dynamically with parameter ?
/*------------------------------------------------------------------------*/
public void OpenForm(string pi_form_dll_name)
{
bool bFindForm = false; Assembly formAsm = null;
try
{
this.Cursor = Cursors.WaitCursor;
formAsm = Assembly.LoadFrom(pi_form_dll_name + ".dll");
Type[] ClassTypes = formAsm.GetTypes();
foreach(Type clsType in ClassTypes)
{
if (clsType.IsSubclassOf(typeof(Form)))
{
object o = System.Activator.CreateInstance(clsType);
MethodInfo mi = clsType.GetMethod("Show"); // here can we invoke property of MdpParent=this instead of invoking method ?
mi.Invoke(o, null); bFindForm = true; break;
}
}
if (bFindForm == false)
{
string sErr = pi_form_dll_name + ".dll does not have " +
"Form-derived class defined";
MessageBox.Show("Form Open Error",sErr);
}
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message,"Form Open Error");
}
finally
{
this.Cursor = Cursors.Arrow;
}
}
/*------------------------------------------------------------------------*/
helps'll be appreciated..
Ahmet