C# linklabel control, introduction to C# linklabel control, intro to C# linklabel control, basics of C# linklabel control
Hey Everyone! Hope you all are doing great and enjoying your lives. My job is to keep you updated with useful information that helps you excel in your relevant field. Today, I am going to give the details on the C# Linklabel Control. This control allows you to display a hyperlink. It exhibits all the properties given by C# Label Control but it is explicitly used for displaying useful information on the hyperlink. I'll try to cover each and every aspect related to C# Linklabel Control so you don't need to go anywhere for finding the information regarding this control. Let's hop on the board and dive in the details of this control and explore its properties step by step.

C# LinkLabel Control

  • C# Linklabel Control is used to display hyperlink to provide useful information.
  • In order to create C# Linklabel control, open the windows form application and go to Toolbar appearing on the left side.
  • Find the Linklabel control, drag and drop it over the Form.
C# linklabel control, introduction to C# linklabel control, intro to C# linklabel control, basics of C# linklabel control
  • You can play with it and move it around over the Form with the help of mouse.
  • There is another way of creating the Linklabel control. Just double click on the Linklabel control, it will automatically place the Linklabel control on the Form.
Linklabel Control Properties
  • In order to set the Linklabel control properties, just right click on the Linklabel control and go to properties.
  • Properties window will appear on the right side of the windows form application.
  • Linklabel control comes with different useful properties including, name, autosize, text, size, font, fontcolor, back color etc. Let's discuss them one by one. Following window will appear as click on the properties.
C# linklabel control, introduction to C# linklabel control, intro to C# linklabel control, basics of C# linklabel control
Name and Text Properties
  • Name property defines the specific name of the control that is used to access it in the code. In the figure above, Linklabel control name is linkLabel1.
  • Similarly, text property is used to display the descriptive text on the link. You can go to properties and change the name manually or you can change it in a code as well.
  • Following code can be used to change the text of the Linklabel Control.
 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
         
            linkLabel1.Text = "this is label one";
        }
BackColor, BorderStyle, ForeColor Properties
  • BackColor property is used to change the background color of the linklable control.
  • BorderStyle is used to give linklable control a specific border style around the link text. It comes with two border styles including FixedSingle, Fixed 3D.
  • ForeColor is used to change the forecolor of the linklabel control.
Font, AutoSize and TextAlign Properties
  • Font property shows the font style of the text that can be used in linklabel control. When you go to properties, and click on Font property, it shows different font styles, size and
  • AutoSize property is used to change the size of the linklable control. By default the value of AutoSize property is true, when it is true, you can not change the size of the linklable. When it is set to false, you can change the size of linklabel.
  • Similarly, TextAlign property is used to align the linklabel text in the linklable control. It comes with 9 different options to align the text at different place on the linklabel control.
Image and ImageAlign Properties
  • Image property is used to set the background of the linklabel control as an image.
  • Similarly, ImganAlign property is used to align the image on the background of the linklabel control.
 Color Properties
  • LinkColor property shows the color of the link in linklabel control.
  • LinkVisited property comes with two states true and false. When it is false, color of the link won't be changed once the link is visited. When it is set true, the color of the link will change once the link is visited.
  • VisitedLinkColor property shows the color of the visited link. By default purple color is set to the VisitedLinkColor property.
  • ActiveLinkColor property represents the color when you put the cursor on the link and click. The color appears before you fully clicked the link is ActiveLinkColor.
Example 1
  • We are going to build a program which will allow the linklabel to open some website.
  • In order to do this, open the windows form application and drag and drop the linklabel from the Toolbar to Form.
  • Double click on the linklabel, following figure will appear.
C# linklabel control, introduction to C# linklabel control, intro to C# linklabel control, basics of C# linklabel control
  • Now add "using System.Diagnostics" in the code just like the shown in the figure below.
C# linklabel control, introduction to C# linklabel control, intro to C# linklabel control, basics of C# linklabel control
  • Now add following code in your application. When you run the application, and click on the link, it will allow the link to open the google website.
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("www.google.com");
        }
That's all for today. Thanks for reading the article. We always love when you keep coming back for what we have to offer. If you have any question you can ask me in the comment section below. I'd love to help you according to best of my expertise. Stay Tuned!