天天看點

C#在代碼中實作超連結

/*評論超連接配接*/

                LinkLabel llb = new LinkLabel();

                llb.Text = "評論";

                llb.AutoSize = true;

                llb.Location = new Point(270, 100 + i * 90);

                this.panel1.Controls.Add(llb);

                //注冊标簽的三個事件

                llb.MouseLeave += new System.EventHandler(this.mouseLeave);

                llb.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkClicked);

                llb.MouseEnter += new System.EventHandler(this.mouseEnter);

//自定義三個控件事件的方法

        private void mouseEnter(object sender, EventArgs e)

        {

            //MessageBox.Show("OK");

        }

        private void mouseLeave(object sender, EventArgs e)

        private void LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

            MessageBox.Show("評論結果尚未添加到資料庫中。。。。");

            this.panel1.Controls.Clear();

            Init();