LinkLabel (aka Hyperlinks)

This shouldn't require explanation, besides the features specific to C#. This is functionally identical to the hyperlinks we've been clicking on websites that take us to other pages or other websites, since the internet started. If this concept is foreign to you, I am geniunely interested in sitting down and discussing how your life thus far hasn't included an internet connection and usage. Seriously.

Objects from the LinkLabel class have properties that you will often want to change, including:

  1. Color LinkColor: the Color of an un-visited link. The default is blue.

  2. Color ActiveLinkColor: the Color of a link as it's being clicked. The default is red.

  3. Color VisitedLinkColor: the Color of a link after it's been visited. The default is purple.

  4. bool LinkVisited: initially set to false. Interestingly, this doesn't update automatically.

  5. string Text: the display text for the hyperlink.

While the conventional hyperlink transitions from blue to red to purple, there's plenty of examples of websites that forgo the conventional color scheme (e.g. NIU web links are often red), as well as discard the changing colors for visited links (as many NIU links do). The reasoning for this could be as simple as branding (NIU is big about using red, black, and white color schemes) or to promote a consistent user experience from one device to another. As long as you are consistent across your entire platform, that's the most important aspect of using LinkLabels.

In HTML, creating hyperlinks is outrageously simple compared to C#. Here, I would simply do something like <a href="https://www.niu.edu/" target="_blank">Click here!</a>. Boom, done. C# will instead generate a LinkLabelLinkClickedEvent (try saying that five times fast!), which then needs to be handled by creating a new process, that then travels to the webpage or file link.

niuLink.Text = "Visit NIU's homepage!";
niuLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(goToNIU);

// other stuff and things
private void goToNIU(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs args)
{
niuLink.LinkVisited = true;
System.Diagnostics.Process.Start("https://www.niu.edu/");
}