通过数据库字段动态加载菜单,点击菜单后通过反射SHOW出窗体,现在的问题是怎么样才能给这些个SHOW的窗口传递参数(string 类型)?
SHOW出窗体的代码如下。
ToolStripMenuItem tsi = sender as ToolStripMenuItem;//得到事件源,强转为菜单项
Assembly asb = Assembly.GetExecutingAssembly();//得到当前的程序集
Form f = (Form)asb.CreateInstance("Test." + tsi.Tag.ToString());//利用反射,根据数据库中的字段值创建窗体对象
foreach (System.Windows.Forms.Form ff in pnc_info.Controls)
{
//如果子窗体存在,激活子窗体
if (ff.Name == f.Name)
{
ff.WindowState = System.Windows.Forms.FormWindowState.Minimized;
ff.Activate();
ff.Size = ff.Parent.Size;
ff.WindowState = System.Windows.Forms.FormWindowState.Maximized;
return;
}
}
f.TopLevel = false; //设置属性
f.Show(); //显示form
------解决方案--------------------------------------------------------
有重载啊
public virtual Object CreateInstance(
string typeName,
bool ignoreCase,
BindingFlags bindingAttr,
Binder binder,