手记

winform中linkLabel的用法示例

 private void Form1_Load(object sender, EventArgs e)
        {
            this.lnkTest.Text = "百度 Google Yahoo";                      
            this.lnkTest.Links.Add(0, 2, "http://www.baidu.com");
            this.lnkTest.Links.Add(3, 6, "http://www.google.com");
        }
        private void lnkTest_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.lnkTest.Links[lnkTest.Links.IndexOf(e.Link)].Visited = true;           
            string target = e.Link.LinkData as string;           
            if (target!=null && target.StartsWith("http://"))
            {
                System.Diagnostics.Process.Start(target);
            }
            else
            {
                MessageBox.Show("Item clicked: " + target);
            }
        }


0人推荐
随时随地看视频
慕课网APP