I’m trying to load a new button for each XML element in an XML Doc. I need to make a new instance of the button for each xml node in the document. The code below works as far as making a new button goes, but the button has a custom Attribute called “money” that keeps getting overwritten. So I’m trying to find some method to dynamically name the button as well, E.G. button (Dynamic Name) = new button();
int x = 0;
int y = 0;
XmlDocument xmlDoc= new XmlDocument(); //* create an xml document object.
xmlDoc.Load("XML.xml");
XmlNodeList elemList = xmlDoc.GetElementsByTagName("item");
for (int i = 0; i < elemList.Count; i++)
{
string money = elemList[i].Attributes["www"].Value;
string itemName = elemList[i].Attributes["money"].Value;
button LB = new button();
LB.Text = money + itemName;
LB.money = itemName;
LB.Location = new System.Drawing.Point(x, y);
x += 25;
y += 25;
LB.Click += new EventHandler(item_click);
this.Controls.Add(LB);
}
try
this works as long as
.moneyis NOT static…