Elliot B. Posted December 3, 2015 Share Posted December 3, 2015 I am using Microsoft Visual Studio Community 2015. I have added a LinkLabel ("LinkLabel1") and changed the text to read www.neowin.net. Now how do I get it to actually go to www.neowin.net when it's clicked? I can't find the option in the Properties dock. I am a beginner - go easy on me! Link to comment Share on other sites More sharing options...
0 ramesees Posted December 3, 2015 Share Posted December 3, 2015 There is an event you have to implement called Link_Clicked: public Form1() { // Create the LinkLabel. this.linkLabel1 = new System.Windows.Forms.LinkLabel(); // Configure the LinkLabel's location. this.linkLabel1.Location = new System.Drawing.Point(34, 56); // Specify that the size should be automatically determined by the content. this.linkLabel1.AutoSize = true; // Add an event handler to do something when the links are clicked. this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); // Set the text for the LinkLabel. this.linkLabel1.Text = "https://www.neowin.net"; // Set up how the form should be displayed and add the controls to the form. this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.linkLabel1 }); this.Text = "Simple Link Label Example"; } private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { // Specify that the link was visited. this.linkLabel1.LinkVisited = true; // Navigate to a URL. System.Diagnostics.Process.Start("https://www.neowin.net"); } Link to comment Share on other sites More sharing options...
0 Elliot B. Posted December 7, 2015 Author Share Posted December 7, 2015 I was hoping I could just add a URL here somewhere: Link to comment Share on other sites More sharing options...
0 Slugsie Posted December 7, 2015 Share Posted December 7, 2015 Unfortunately it doesn't work like that. There are 2 bits of sample code on MSDN for using the LinkLabel which should give you enough to get started, but in essence Ramesees answer is the way it works. https://msdn.microsoft.com/en-us/library/system.windows.forms.linklabel(v=vs.110).aspx Link to comment Share on other sites More sharing options...
Question
Elliot B.
I am using Microsoft Visual Studio Community 2015.
I have added a LinkLabel ("LinkLabel1") and changed the text to read www.neowin.net.
Now how do I get it to actually go to www.neowin.net when it's clicked?
I can't find the option in the Properties dock.
I am a beginner - go easy on me!
Link to comment
Share on other sites
3 answers to this question
Recommended Posts