LinkLabel is a class that is derived from label class so it has all the functions of label class. But LinkLabel control works as a hyperlink and its appearance is also a hyperlink.
Drag and drop LinkLabel control from the toolbox on the window Form.
Code:
Write code on LinkClicked event
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//after visiting site LinkLabel color changed which will indicate that you have visited this site
linkLabel1.LinkVisited = true;
System.Diagnostics.Process.Start("www.mindstick.com");
//using the start method of system.diagnostics.process class
//process class gives access to local and remote processes
}
System.Diagnostics.Process.Start
The System. The Diagnostics namespace exposes a Process class that you can use to launch external programs. We can launch a new process with the shared Process. The Start method, passing it either the name of an executable file or a filename with an extension associated with an executable application.
Run the project
When you click on the link Go to google then the LinkClicked event will fire and redirected to www.google.com.
LinkLabel Properties:
LinkBehaviour: The behavior of link can be changed through LinkBehaviour properties LinkLabel.
Example:
private void Form9_Load(object sender, EventArgs e)
{
//disable underline
linkLabel1.LinkBehavior = LinkBehavior.NeverUnderline;
}
Now when the application runs then Underline will not show in LinkLabel.
ForeColor: set the foreground color of the LinkLabel control.
BackColor: set the background color of LinkLabel control.
Example:
private void Form9_Load(object sender, EventArgs e)
{
//change BackColor of LinkLabel
linkLabel1.BackColor = Color.CadetBlue;
}
Anonymous User
01-Mar-2019Nice Post.
Samuel Fernandes
08-Aug-2017Keep sharing these types of articles.