我在 c# 中生成了一堆链接标签。我想要的是用一个 URL 填充 textBox1,每个链接标签都不同。我将如何生成动态事件?这是一个例子:
foreach (var node in nodes)
{
HtmlAttribute att = node.Attributes["href"];
HtmlAgilityPack.HtmlDocument tempDoc = new HtmlAgilityPack.HtmlDocument();
tempDoc.LoadHtml(node.InnerHtml);
var tempNode = tempDoc.DocumentNode.SelectSingleNode("//img[@alt]");
HtmlAttribute tempAtt = tempNode.Attributes["alt"];
LinkLabel ll = new LinkLabel();
ll.Location = new Point(20, 20 * i);
ll.Text = tempAtt.Value;
this.Controls.Add(ll);
i++;
}
节点文本应为tempAtt.Value
,单击时 textBox1 应填充att.Value