devxlogo

Create and Execute Web Links with the LinkLabel Control

Create and Execute Web Links with the LinkLabel Control

Visual Basic .NET makes Web links easy with the LinkLabel control. You’ll find this control in the standard Visual Basic.NET Toolbox. Simply click on it, draw it on your form, and set the Text property to your desired URL. To navigate to the link, add the following code to the LinkClicked() event of the LinkLabel:

	System.Diagnostics.Process.Start _(LinkLabel1.Text)

The Start method of the Process class executes the application string to which you pass it. If you don’t supply an application to the method, the text you pass to it dictates which application the system launches. So, if you just pass it a URL, it opens it using Microsoft Internet Explorer.

The LinkLabel control comes equipped with quite a few properties to help you create the perfect Web link. For example, you can enter lines and lines of text into the control’s Text property. Then, use the LinkArea property and associated LinkArea Editor to select only the text you want for the link. You can also specify whether the text has a permanent underline, no underline, or an underline visible only when the user hovers over the link using the LinkBehavior property. The valid values for this property are SystemDefault, AlwaysUnderline, HoverUnderline, and NeverUnderline. For additional customization, change the default link color and visited link color using the LinkColor and VisitedLinkColor properties. You can even embed an image right into the link using the Image property.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist