在RichTextBox控件中添加超链接文本

实现效果:

  

知识运用:

  RichTextBox控件的AppendText方法

  public void AppendText{string textData}    //向控件中添加文本内容

  和Process类的Start方法

  public static Process Start(string fileName,string arguments)  //启动一个进程资源

  //参数分别对应 (要在进程中运行的进程的文件名称    启动进程时传递的命令行参数)

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            rtbox_HyperLink.AppendText(@"
         谷歌:https://www.google.com
         网易:https://www.163.com
         百度:https://www.baidu.com
         奇虎:https://www.so.com");
        }

        private void rtbox_HyperLink_LinkClicked(object sender, LinkClickedEventArgs e)
        {
            Process.Start("iexplore.exe",e.LinkText);
        }

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10152768.html