会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
︷起↘嚸.
坚持不懈,一步一个台阶
博客园
首页
新随笔
新文章
联系
管理
订阅
Winform--处理MDI父窗体与子窗体的交互
设置个窗体只能弹出一次
设置个窗体只能弹出一次
#region
设置个窗体只能弹出一次
/**/
/**/
/**/
///
<summary>
///
控制只弹出一个子窗体
///
</summary>
///
<param name="type">
子窗体类型
</param>
public
void
FilmShow(Type type)
{
Form[] f
=
this
.MdiChildren;
foreach
(Form form
in
f)
{
if
(form.GetType().Name
==
type.Name)
{
form.Activate();
return
;
}
}
Assembly a
=
Assembly.GetExecutingAssembly();
Form ff
=
(Form)a.CreateInstance(type.FullName);
ff.MdiParent
=
this
;
ff.Show();
//
this.statusBarPanel3.Text = this.ActiveMdiChild.Text.ToString();
}
/**/
/**/
/**/
///
<summary>
///
该窗体以模式窗体形式弹出
///
</summary>
///
<param name="type"></param>
public
void
FilmShowDialog(Type type)
{
Form[] f
=
this
.MdiChildren;
foreach
(Form form
in
f)
{
if
(form.GetType().Name
==
type.Name)
{
form.Activate();
return
;
}
}
Assembly a
=
Assembly.GetExecutingAssembly();
Form ff
=
(Form)a.CreateInstance(type.FullName);
ff.ShowDialog();
//
this.statusBarPanel3.Text = this.ActiveMdiChild.Text.ToString();
}
#endregion
下面是如果调用该方法
private
void
menuItem2_Click(
object
sender, System.EventArgs e)
{
//
密码修改,弹出模式窗体
this
.FilmShowDialog(
typeof
(AdminPwdUpdate));
}
private
void
menuItem4_Click(
object
sender, System.EventArgs e)
{
//
类别管理,弹出子窗体
this
.FilmShow(
typeof
(TypeForm));
}
,
这个送给你!
posted on
2008-07-18 10:19
︷起↘嚸.
阅读(
629
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告