// // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(584, 341); this.IsMdiContainer = true; this.Menu = this.mainMenu1; this.Name = "Form1"; this.Text = "Form1"; } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } // //使用反射生成菜单事件 // private void NewClick(object sender, System.EventArgs e) { MenuItem item = (MenuItem)sender; MenuItem par = (MenuItem)item.Parent; int i = par.Index; int j = item.Index; string iDll = mDlls[i][j]; string iClass = iDll.Substring(0,iDll.IndexOf(".")) + "." + iDll.Substring(0,iDll.IndexOf(".")); string iFunc = mFuncs[i][j]; try { Assembly asm = Assembly.LoadFrom(iDll); Type mytype = asm.GetType(iClass); MethodInfo mi = mytype.GetMethod(iFunc); object obj = Activator.CreateInstance(mytype); mi.Invoke(obj,new object[] {this}); }
|