using System;
using System.Drawing;
using System.Windows.Forms;
public class LinkLabelGenericAddHandler : Form {
public LinkLabelGenericAddHandler(){
Size = new Size(300,250);
LinkLabel lnkSterSol = new LinkLabel();
lnkSterSol.Parent = this;
lnkSterSol.Text = "www.java2java.com";
lnkSterSol.Location = new Point(0,50);
lnkSterSol.AutoSize = true;
lnkSterSol.BorderStyle = BorderStyle.None;
lnkSterSol.Links.Add(0,lnkSterSol.Text.ToString().Length,"www.java2java.com");
lnkSterSol.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(lnkGeneric_LinkClicked);
}
static void Main()
{
Application.Run(new LinkLabelGenericAddHandler());
}
private void lnkGeneric_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
LinkLabel lnk = new LinkLabel();
lnk = (LinkLabel)sender;
lnk.Links[lnk.Links.IndexOf(e.Link)].Visited = true;
System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
}
}
|