I have dynamically added a few items to my Menu Strip and triggered and event for each item added to the strip (items are added from an XML file). What I'm trying to do next is to pass the text from each item to the event handler so I can use them in a thread. Is it possible to this? Can anyone help me with a solution please?
This is my code:
private void historyMenuItem_Click(object sender, EventArgs e){
XmlDocument doc = new XmlDocument(); // create new xml document
doc.Load("..\\history.xml"); // load the xml
// create a new node list
// and select nodes from BookItems/Book
XmlNodeList nodeList = doc.SelectNodes("URLs/http");
historyMenuItem.DropDownItems.Clear();
foreach (XmlNode node in nodeList) {
string page = node.Attributes["page"].Value;
//http://msdn.microsoft.com/en-us/library/ms160990.aspx
ToolStripMenuItem windowNewMenu = new ToolStripMenuItem(page, null, new EventHandler(MenuItemClickHandler));
historyMenuItem.DropDownItems.Add(windowNewMenu);
}
}
private void MenuItemClickHandler(object sender, EventArgs e){
ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
## HERE IS WHERE I NEED HELP:
UrlTextBox = (I need value of page here!);
this.thread = new Thread(new ThreadStart(this.httpRequestMultiThread));
this.thread.Start();
}