--- title: Change the Appearance of LinkLabel Control ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "LinkLabel properties" - "LinkLabel control [Windows Forms], changing appearance of links" - "links [Windows Forms], changing appearance" - "examples [Windows Forms], LinkLabel control" - "LinkLabel control [Windows Forms], examples" ms.assetid: fdc5854f-5162-4457-8cbe-1042feb2d132 --- # How to: Change the Appearance of the Windows Forms LinkLabel Control You can change the text displayed by the control to suit a variety of purposes. For example, it is common practice to indicate to the user that text can be clicked by setting the text to appear in a specific color with an underline. After the user clicks the text, the color changes to a different color. To control this behavior, you can set five different properties: the , , , , and properties. ### To change the appearance of a LinkLabel control 1. Set the and properties to the colors you want. This can be done either programmatically or at design time in the **Properties** window. ```vb ' You can set the color using decimal values for red, green, and blue LinkLabel1.LinkColor = Color.FromArgb(0, 0, 255) ' Or you can set the color using defined constants LinkLabel1.VisitedLinkColor = Color.Purple ``` ```csharp // You can set the color using decimal values for red, green, and blue linkLabel1.LinkColor = Color.FromArgb(0, 0, 255); // Or you can set the color using defined constants linkLabel1.VisitedLinkColor = Color.Purple; ``` ```cpp // You can set the color using decimal values for red, green, and blue linkLabel1->LinkColor = Color::FromArgb(0, 0, 255); // Or you can set the color using defined constants linkLabel1->VisitedLinkColor = Color::Purple; ``` 2. Set the property to an appropriate caption. This can be done either programmatically or at design time in the **Properties** window. ```vb LinkLabel1.Text = "Click here to see more." ``` ```csharp linkLabel1.Text = "Click here to see more."; ``` ```cpp linkLabel1->Text = "Click here to see more."; ``` 3. Set the property to determine which part of the caption will be indicated as a link. The value is represented with a containing two numbers, the starting character position and the number of characters. This can be done either programmatically or at design time in the **Properties** window. ```vb LinkLabel1.LinkArea = new LinkArea(6,4) ``` ```csharp linkLabel1.LinkArea = new LinkArea(6,4); ``` ```cpp linkLabel1->LinkArea = LinkArea(6,4); ``` 4. Set the property to , , or . If it is set to , the part of the caption determined by will only be underlined when the pointer rests on it. 5. In the event handler, set the property to `true`. When a link has been visited, it is common practice to change its appearance in some way, usually by color. The text will change to the color specified by the property. ```vb Protected Sub LinkLabel1_LinkClicked (ByVal sender As Object, _ ByVal e As EventArgs) Handles LinkLabel1.LinkClicked ' Change the color of the link text ' by setting LinkVisited to True. LinkLabel1.LinkVisited = True ' Then do whatever other action is appropriate End Sub ``` ```csharp protected void LinkLabel1_LinkClicked(object sender, System.EventArgs e) { // Change the color of the link text by setting LinkVisited // to True. linkLabel1.LinkVisited = true; // Then do whatever other action is appropriate } ``` ```cpp private: System::Void linkLabel1_LinkClicked(System::Object ^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs ^ e) { // Change the color of the link text by setting LinkVisited // to True. linkLabel1->LinkVisited = true; // Then do whatever other action is appropriate } ``` ## See also - - - - - [LinkLabel Control Overview](linklabel-control-overview-windows-forms.md) - [How to: Link to an Object or Web Page with the Windows Forms LinkLabel Control](link-to-an-object-or-web-page-with-wf-linklabel-control.md) - [LinkLabel Control](linklabel-control-windows-forms.md)