Add LinkLabel to Form

The tools when customizing a form doesn’t have the linklabel. I want to link to hyperlink. Anyone have some code examples to add these? Below is what I have so far, but it doesn’t like my code to add the controls to the form.

// **************************************************
// Custom form code MES
// Created: 8/21/2017 2:24:27 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using Erp.Adapters;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **

// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **

private System.Windows.Forms.LinkLabel linkLabel1;

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls
		 // Add an event handler to do something when the links are clicked.
        linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(linkLabel1_LinkClicked);
	
	// End Wizard Added Custom Method Calls

}

public void DestroyCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	// Begin Wizard Added Object Disposal

	

	// Begin Custom Code Disposal
        // Add an event handler to do something when the links are clicked.
        linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(linkLabel1_LinkClicked);
	// End Custom Code Disposal
}


	
	//Custom code to handle linklabel click event
   private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
    {
        // Specify that the link was visited.
        linkLabel1.LinkVisited = true;

        // Navigate to a URL.
        System.Diagnostics.Process.Start("http://localhost/TestVS/");
    }



private void MESMenu_Load(object sender, EventArgs args)
{
	// Add Event Handler Code

		// Create the LinkLabel.
        linkLabel1 = new System.Windows.Forms.LinkLabel();

        // Configure the LinkLabel's location. 
        linkLabel1.Location = new System.Drawing.Point(32, 6);
        // Specify that the size should be automatically determined by the content.
        linkLabel1.AutoSize = true;

        // Set the text for the LinkLabel.
        linkLabel1.Text = "AMP Part Labels";

        // Set up how the form should be displayed and add the controls to the form.
        ClientSize = new System.Drawing.Size(73, 50);
        Controls.AddRange(new System.Windows.Forms.Control[] { this.linkLabel1 });
}

}

Here is a link to a nice tutorial by @josecgomez that covers everything you need to get this done.

2 Likes