Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to use LinkLabel?

How to use LinkLabel?

Scheduled Pinned Locked Moved C#
helptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chaitanya Joshi
    wrote on last edited by
    #1

    Dear friends, I intend to use LinkLabels in my project. But I am toally jumbled with it because I am not getting the exact place where the actual link should be stored. I studied its properties like LinkArea, LinkData, Links and Link types. But I am totally entangled with it. I want to display a text and underlying link and connect it to webbrowser. the later part is easy coz' I know LinkLabel's event to handle. But Plz help me with above problem. Thanks in Advance..

    A N 2 Replies Last reply
    0
    • C Chaitanya Joshi

      Dear friends, I intend to use LinkLabels in my project. But I am toally jumbled with it because I am not getting the exact place where the actual link should be stored. I studied its properties like LinkArea, LinkData, Links and Link types. But I am totally entangled with it. I want to display a text and underlying link and connect it to webbrowser. the later part is easy coz' I know LinkLabel's event to handle. But Plz help me with above problem. Thanks in Advance..

      A Offline
      A Offline
      Arjun Marwaha
      wrote on last edited by
      #2

      Hello, The following might help you in achieving the desired: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.linkLabel1.Text = "Register Online. Visit Microsoft. Visit MSN."; if (this.linkLabel1.Text.Length >= 45) { this.linkLabel1.Links[0].LinkData = "Register"; this.linkLabel1.Links.Add(24, 9, "www.microsoft.com"); this.linkLabel1.Links.Add(42, 3, "www.msn.com"); } } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string target = e.Link.LinkData as string; if (null != target && target.StartsWith("www")) { System.Diagnostics.Process.Start(target); } else { MessageBox.Show("Item clicked: " + target); } } } } Regards, Dave

      Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com

      C 1 Reply Last reply
      0
      • C Chaitanya Joshi

        Dear friends, I intend to use LinkLabels in my project. But I am toally jumbled with it because I am not getting the exact place where the actual link should be stored. I studied its properties like LinkArea, LinkData, Links and Link types. But I am totally entangled with it. I want to display a text and underlying link and connect it to webbrowser. the later part is easy coz' I know LinkLabel's event to handle. But Plz help me with above problem. Thanks in Advance..

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Chaitanya Joshi wrote:

        I am not getting the exact place where the actual link should be stored

        I am not getting what you are saying ? Are you facing difficulty in opening a web page when link button is clicked ? Use Process.Start to start a new browser and also send URL to be opened.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

        1 Reply Last reply
        0
        • A Arjun Marwaha

          Hello, The following might help you in achieving the desired: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.linkLabel1.Text = "Register Online. Visit Microsoft. Visit MSN."; if (this.linkLabel1.Text.Length >= 45) { this.linkLabel1.Links[0].LinkData = "Register"; this.linkLabel1.Links.Add(24, 9, "www.microsoft.com"); this.linkLabel1.Links.Add(42, 3, "www.msn.com"); } } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string target = e.Link.LinkData as string; if (null != target && target.StartsWith("www")) { System.Diagnostics.Process.Start(target); } else { MessageBox.Show("Item clicked: " + target); } } } } Regards, Dave

          Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com

          C Offline
          C Offline
          Chaitanya Joshi
          wrote on last edited by
          #4

          Thank You Sir. The code snippet you gave worked perfectly fine. So finally the "linkdata" is the attribute where we've to add the actual link.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups