会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Net而立之路
Net而立之路
博客园
首页
新随笔
联系
管理
订阅
利用反射,实现动态调用winform窗体
实用前提:在WinForm程序中,通过主窗体的Menu打开不同的窗体
我以前的做法:在Menu的Click事件中,创建打开窗体的对象实例
这样的缺点,我不说了:)
看看利用反射动态调用窗体对象的方法:
Code
private
void
CreateForm(
string
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;
}
这样的好处,也自己看吧,:)
posted @
2009-02-19 12:13
lastgame
阅读(
1192
) 评论(
3
)
收藏
举报
刷新页面
返回顶部
公告