public SplitterPanel splitterPanel2; public XmlNode xmlNode; public string userId; public void SetLabel(Label la) { la.Click += new EventHandler(Label_Click); la.MouseHover += new EventHandler(Mouse_Hover); la.MouseLeave += new EventHandler(Mouse_Leave); } public void Label_Click(object sender, EventArgs e) //利用反射的方法实现不同按钮的事件响应 { try { Assembly a; a = Assembly.LoadFile(Application.StartupPath + "//" + xmlNode.Attributes["dll"].Value); Type t = a.GetType(xmlNode.Attributes["class"].Value, false, true); MethodInfo method = t.GetMethod(xmlNode.Attributes["method"].Value); ConstructorInfo coninfo = t.GetConstructor(new Type[] { typeof(SplitterPanel), typeof(XmlNode), typeof(string) }); object[] arg = new object[3] { splitterPanel2, xmlNode, userId }; object obj = coninfo.Invoke(arg); method.Invoke(obj, null); } catch (Exception ee) { MessageBox.Show(ee.ToString()); } } public SplitterPanel splitterPanel2; public XmlNode xmlNode; public string userId; public BackForm(SplitterPanel splitterPanel2, XmlNode xmlNode, string userId) { this.splitterPanel2 = splitterPanel2; this.xmlNode = xmlNode; this.userId = userId; } public void Addform() { AddForm af = new AddForm(); af.TopLevel = false; af.Top = 0; af.Left = 0; af.Anchor = AnchorStyles.Top; af.Anchor = AnchorStyles.Left; af.Show(); splitterPanel2.Controls.Add(af); af.BringToFront(); //实现最上一层的显示 } <panel title="panel1" text="panel1" type="panel" show="true" > <lable title="lable" text="公司信息添加" type="lable" dll="InfoAdd.dll" class="InfoAdd.BackForm" method="Addform"/> 所有的DLL调用都用XML来处理