原链接:http://www.cnblogs.com/lastgame/archive/2009/02/19/1393831.html

 

实用前提:在WinForm程序中,通过主窗体的Menu打开不同的窗体
我以前的做法:在Menu的Click事件中,创建打开窗体的对象实例
这样的缺点,我不说了:)
看看利用反射动态调用窗体对象的方法:
 strName)
{
this.Cursor = Cursors.WaitCursor;

string path=AssemblyName;//项目的Assembly选项名称
string name=strName; //类的名字

Form fm
=(Form)Assembly.Load(path).CreateInstance(name);
fm.MdiParent
=this.ParentForm;
fm.Show();
fm.Dock
=DockStyle.Fill;
this.Cursor = Cursors.Default;


这样的好处,也自己看吧,:)

相关文章:

  • 2022-12-23
  • 2021-08-16
  • 2022-01-05
  • 2021-12-25
  • 2021-10-12
  • 2021-11-27
猜你喜欢
  • 2021-10-27
  • 2021-06-06
  • 2022-12-23
  • 2021-11-12
  • 2021-10-10
  • 2021-12-03
  • 2021-10-14
相关资源
相似解决方案