private void SQLSet_Load(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load("sqlset.xml");
XmlNode xn = doc.SelectSingleNode("config");
//得到config的子节点
XmlNodeList xnl = xn.ChildNodes;
int i = 0;
int k = 0;
foreach (XmlNode xn1 in xnl)
{
XmlElement xe = (XmlElement)xn1;
GroupBox groupBox = new GroupBox();
groupBox.Text = xe.Attributes["name"].Value;
groupBox.Width = 350;
groupBox.Height = 200;
groupBox.Location = new Point(20 + i * 400, 12);
this.Controls.Add(groupBox);
i = i + 1;
int j = 0;
XmlNodeList xn2 = xe.ChildNodes;
foreach (XmlNode item in xn2)
{
Button button = new Button();
button.Text = item.Attributes["name"].Value;
button.Name = item.Attributes["key"].Value;
// string name= item.Attributes["key"].Value;
button.Location = new Point(20 + j * 100, 22);
groupBox.Controls.Add(button);
button.Tag = k;
button.Click += new EventHandler(btn_click);
//button.Click+= (s, e) => { btn_click };
j = j + 1;
k = k + 1;
}
}
}
for(){
btn=new btn();
btn.tag=k;
btn.click=onclick;
}
onclick(obj,e){
switch(obj.tag)
//不同的按钮,走不同的case,或者建立对应关系
}
谢谢你了