您的位置:首页 > 编程语言 > C#

C#泛型编程用于FORM调用,简化代码

2008-11-01 10:02 155 查看
使用

FormMngr<FormQry>.showMdiChild<FormQry>(this);
实现

public class FormMngr<T> where T : Form
{
public static int I = 0;
private static System.Collections.SortedList fList = new System.Collections.SortedList();
public static void showMdiChild<T>(Form p_midparnt) where T : new()
{
string me = typeof(T).ToString();
if (fList.Contains(me))
{
Form f = fList[me] as Form;
(f as Form).Activate();
return;
} else
{
T fqry = (T)new T();
(fqry as Form).MdiParent = p_midparnt;//.M;
fList.Add(me, fqry);
(fqry as Form).Show();
}
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: