Hello Michael ,
And instead of using Assembly u can change these 2 lines below
// Get current assembly
Assembly frmMain = Assembly.GetEntryAssembly();
// Get Type of your form
System.Type formType = frmMain.GetType("WindowsApplication1.frmAbout");
on this
Type formType = typeof(WindowsApplication1.frmAbout);
MN> Hello wu,
MN>
MN> See this code. Comments expain how it works
MN>
MN> // Get current assembly
MN> Assembly frmMain = Assembly.GetEntryAssembly();
MN> // Get Type of your form
MN> System.Type formType =
MN> frmMain.GetType("WindowsApplication1.frmAbout");
MN> // Create instance of form
MN> object pc = Activator.CreateInstance(formType);
MN> // Cast to Form class
MN> Form frm = (Form)pc;
MN> // Show Form
MN> frm.Show();
wj>> hi.
wj>> If I have a form, like FrmAbout, can I create a form instance only
wj>> with a
wj>> string "FrmAbout"?
wj>> not like : Form frm = new FrmAbout();
wj>> I want the code : Form frm = createInstance( "FrmAbout" );
wj>> How to code my createInstance function?
wj>> Thanks.
MN> ---
MN> WBR,
MN> Michael Nemtsev :: blog:
http://spaces.msn.com/laflour
MN> "At times one remains faithful to a cause only because its opponents
MN> do not cease to be insipid." (c) Friedrich Nietzsche
MN>
---
WBR,
Michael Nemtsev :: blog:
http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche