Dictionary<String,String> pdfs = new Dictionary<String, String>(){And the Event Handler
{"Apple","http://www.example.com/apple.pdf"},
{"Banana","http://www.example.com/banana.pdf"},
{"Orange","http://www.example.com/orange.pdf"},
};
LinkLabel[] labels = new LinkLabel[pdfs.Length];
for(KeyValuePair<string, string> pair in pdfs){
label[i] = new Label();
label[i].Name = "label"+i;
label[i].Location = new Point(27,i*30);
label[i].TabStop = true;
label[i].Text = pair.Key;
label[i].Links[0].LinkData = pair.Value;
this.Controls.Add(labels[i]);
}
private void linkedLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e){Referecne:
System.Diagnostics.Process.Start(e.Link.LinkData as string);
}
https://www.dotnetperls.com/dictionary
No comments :
Post a Comment