我正在尝试通过单击树视图节点来加载表单。下面的代码正在运行,但现在我需要将一些变量传递给加载表单。那么有没有办法在从树视图加载表单时传递变量。
string item = Convert.ToString(treeView1.SelectedNode);
int index = item.IndexOf(" ");
if (index > 0)
item = item.Substring(index + 1);
//MessageBox.Show(item);
var selectedFRM = from Menu in dbdata.Menus
where Menu.Item_Name == item
select Menu;
foreach (var pick in selectedFRM.Take(1))
{
string sel = pick.Form_Name;
//Assembly asm = typeof(frmUser).Assembly;
Assembly asm = typeof(frmCustomer).Assembly;
Type type = asm.GetType("WindowsFormsApplication6." + sel);
AssemblyName assemName = asm.GetName();
// MessageBox.Show(assemName.Name);
try
{
Form frmChk = (Form)Activator.CreateInstance(type);
//frmChk cgh = new frmChk();
frmChk.Show();
}
catch (Exception)
{
MessageBox.Show("Error in loading form");
}
}